From a24f3ca25e78f411720fb833202aee400d2b337b Mon Sep 17 00:00:00 2001 From: Peng Jiahui <46921893+Alancere@users.noreply.github.com> Date: Wed, 29 Mar 2023 16:24:26 +0800 Subject: [PATCH] Release refresh all package 1679973755 (#20485) * [Release] sdk/resourcemanager/blockchain/armblockchain/0.6.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/blueprint/armblueprint/0.6.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/botservice/armbotservice/1.1.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/changeanalysis/armchangeanalysis/1.1.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/chaos/armchaos/0.6.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/cognitiveservices/armcognitiveservices/1.4.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/commerce/armcommerce/0.2.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/confidentialledger/armconfidentialledger/1.1.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/confluent/armconfluent/1.1.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * [Release] sdk/resourcemanager/connectedvmware/armconnectedvmware/0.2.0 generation from spec commit: 2ac8dec9cbc4ad4db7537de603339f069d482078 * update changelog and reademe * reset blueprint --- .../blockchain/armblockchain/CHANGELOG.md | 6 + .../blockchain/armblockchain/README.md | 16 +- .../blockchain/armblockchain/autorest.md | 2 +- .../armblockchain/client_factory.go | 70 + ...zz_generated_constants.go => constants.go} | 3 +- .../blockchain/armblockchain/go.mod | 22 +- .../blockchain/armblockchain/go.sum | 48 +- ...ocations_client.go => locations_client.go} | 48 +- .../locations_client_example_test.go | 83 + ...nt.go => memberoperationresults_client.go} | 39 +- ...beroperationresults_client_example_test.go | 43 + ...ed_members_client.go => members_client.go} | 152 +- .../members_client_example_test.go | 380 ++++ .../{zz_generated_models.go => models.go} | 11 +- .../blockchain/armblockchain/models_serde.go | 1119 ++++++++++ ...rations_client.go => operations_client.go} | 30 +- .../operations_client_example_test.go | 189 ++ ...ed_response_types.go => response_types.go} | 19 +- ...enerated_skus_client.go => skus_client.go} | 33 +- .../armblockchain/skus_client_example_test.go | 61 + ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...s_client.go => transactionnodes_client.go} | 149 +- .../transactionnodes_client_example_test.go | 254 +++ ...chainmemberoperationresults_client_test.go | 39 - ...d_example_blockchainmembers_client_test.go | 205 -- ...generated_example_locations_client_test.go | 64 - ...enerated_example_operations_client_test.go | 41 - .../ze_generated_example_skus_client_test.go | 37 - ...ed_example_transactionnodes_client_test.go | 153 -- .../zz_generated_models_serde.go | 188 -- .../botservice/armbotservice/CHANGELOG.md | 6 + .../botservice/armbotservice/README.md | 16 +- .../botservice/armbotservice/autorest.md | 2 +- .../armbotservice/botconnection_client.go | 116 +- .../botconnection_client_example_test.go | 160 +- .../botservice/armbotservice/bots_client.go | 100 +- .../armbotservice/bots_client_example_test.go | 284 ++- .../armbotservice/channels_client.go | 105 +- .../channels_client_example_test.go | 410 +++- .../armbotservice/client_factory.go | 94 + .../botservice/armbotservice/constants.go | 2 +- .../armbotservice/directline_client.go | 40 +- .../directline_client_example_test.go | 54 +- .../botservice/armbotservice/email_client.go | 34 +- .../email_client_example_test.go | 17 +- .../botservice/armbotservice/go.mod | 22 +- .../botservice/armbotservice/go.sum | 45 +- .../armbotservice/hostsettings_client.go | 30 +- .../hostsettings_client_example_test.go | 20 +- .../botservice/armbotservice/models.go | 15 +- .../botservice/armbotservice/models_serde.go | 172 +- .../armbotservice/operationresults_client.go | 39 +- .../operationresults_client_example_test.go | 16 +- .../armbotservice/operations_client.go | 28 +- .../operations_client_example_test.go | 57 +- .../armbotservice/polymorphic_helpers.go | 2 +- .../privateendpointconnections_client.go | 83 +- ...endpointconnections_client_example_test.go | 105 +- .../privatelinkresources_client.go | 36 +- ...rivatelinkresources_client_example_test.go | 25 +- .../qnamakerendpointkeys_client.go | 34 +- ...namakerendpointkeys_client_example_test.go | 16 +- .../armbotservice/response_types.go | 14 +- .../botservice/armbotservice/time_rfc3339.go | 2 +- .../armchangeanalysis/CHANGELOG.md | 6 + .../armchangeanalysis/README.md | 16 +- .../armchangeanalysis/autorest.md | 2 +- ...ed_changes_client.go => changes_client.go} | 54 +- .../changes_client_example_test.go | 172 ++ .../armchangeanalysis/client_factory.go | 54 + ...zz_generated_constants.go => constants.go} | 3 +- .../changeanalysis/armchangeanalysis/go.mod | 22 +- .../changeanalysis/armchangeanalysis/go.sum | 48 +- .../{zz_generated_models.go => models.go} | 11 +- .../armchangeanalysis/models_serde.go | 481 +++++ ...rations_client.go => operations_client.go} | 30 +- .../operations_client_example_test.go | 62 + ...es_client.go => resourcechanges_client.go} | 37 +- .../resourcechanges_client_example_test.go | 96 + ...ed_response_types.go => response_types.go} | 9 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...e_generated_example_changes_client_test.go | 72 - ...enerated_example_operations_client_test.go | 41 - ...ted_example_resourcechanges_client_test.go | 46 - .../zz_generated_models_serde.go | 56 - .../chaos/armchaos/CHANGELOG.md | 6 + sdk/resourcemanager/chaos/armchaos/README.md | 16 +- .../chaos/armchaos/autorest.md | 2 +- ...ities_client.go => capabilities_client.go} | 103 +- .../capabilities_client_example_test.go | 153 ++ ...es_client.go => capabilitytypes_client.go} | 50 +- .../capabilitytypes_client_example_test.go | 92 + .../chaos/armchaos/client_factory.go | 69 + ...zz_generated_constants.go => constants.go} | 3 +- ...iments_client.go => experiments_client.go} | 167 +- .../experiments_client_example_test.go | 591 ++++++ sdk/resourcemanager/chaos/armchaos/go.mod | 22 +- sdk/resourcemanager/chaos/armchaos/go.sum | 48 +- .../{zz_generated_models.go => models.go} | 27 +- .../chaos/armchaos/models_serde.go | 1794 +++++++++++++++++ ...rations_client.go => operations_client.go} | 30 +- ...phic_helpers.go => polymorphic_helpers.go} | 3 +- ...ed_response_types.go => response_types.go} | 23 +- ...ed_targets_client.go => targets_client.go} | 93 +- .../armchaos/targets_client_example_test.go | 169 ++ ...ttypes_client.go => targettypes_client.go} | 45 +- .../targettypes_client_example_test.go | 94 + ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...erated_example_capabilities_client_test.go | 125 -- ...ted_example_capabilitytypes_client_test.go | 66 - ...nerated_example_experiments_client_test.go | 312 --- ...e_generated_example_targets_client_test.go | 128 -- ...nerated_example_targettypes_client_test.go | 64 - .../armchaos/zz_generated_models_serde.go | 438 ---- .../armcognitiveservices/CHANGELOG.md | 6 + .../armcognitiveservices/README.md | 18 +- .../armcognitiveservices/accounts_client.go | 73 +- .../accounts_client_example_test.go | 48 +- .../armcognitiveservices/autorest.md | 2 +- .../armcognitiveservices/client_factory.go | 89 + .../commitmentplans_client.go | 97 +- .../commitmentplans_client_example_test.go | 56 +- .../commitmenttiers_client.go | 21 +- .../commitmenttiers_client_example_test.go | 4 +- .../armcognitiveservices/constants.go | 2 +- .../deletedaccounts_client.go | 33 +- .../deletedaccounts_client_example_test.go | 12 +- .../deployments_client.go | 41 +- .../deployments_client_example_test.go | 16 +- .../armcognitiveservices/go.mod | 22 +- .../armcognitiveservices/go.sum | 45 +- .../armcognitiveservices/management_client.go | 25 +- .../management_client_example_test.go | 8 +- .../armcognitiveservices/operations_client.go | 21 +- .../operations_client_example_test.go | 4 +- .../privateendpointconnections_client.go | 41 +- ...endpointconnections_client_example_test.go | 16 +- .../privatelinkresources_client.go | 21 +- ...rivatelinkresources_client_example_test.go | 4 +- .../resourceskus_client.go | 21 +- .../resourceskus_client_example_test.go | 4 +- .../commerce/armcommerce/CHANGELOG.md | 6 + .../commerce/armcommerce/README.md | 18 +- .../commerce/armcommerce/autorest.md | 2 +- .../commerce/armcommerce/client_factory.go | 50 + ...zz_generated_constants.go => constants.go} | 3 +- .../commerce/armcommerce/go.mod | 22 +- .../commerce/armcommerce/go.sum | 48 +- .../{zz_generated_models.go => models.go} | 3 +- .../commerce/armcommerce/models_serde.go | 525 +++++ ...phic_helpers.go => polymorphic_helpers.go} | 3 +- ..._ratecard_client.go => ratecard_client.go} | 39 +- .../ratecard_client_example_test.go | 59 + ...ed_response_types.go => response_types.go} | 3 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...es_client.go => usageaggregates_client.go} | 39 +- ..._generated_example_ratecard_client_test.go | 38 - .../armcommerce/zz_generated_models_serde.go | 263 --- .../armconfidentialledger/CHANGELOG.md | 6 + .../armconfidentialledger/README.md | 16 +- .../armconfidentialledger/autorest.md | 2 +- .../{zz_generated_client.go => client.go} | 33 +- ..._client_test.go => client_example_test.go} | 21 +- .../armconfidentialledger/client_factory.go | 54 + ...zz_generated_constants.go => constants.go} | 3 +- .../armconfidentialledger/go.mod | 22 +- .../armconfidentialledger/go.sum | 48 +- ...ated_ledger_client.go => ledger_client.go} | 109 +- .../ledger_client_example_test.go | 368 ++++ .../{zz_generated_models.go => models.go} | 11 +- .../armconfidentialledger/models_serde.go | 652 ++++++ ...rations_client.go => operations_client.go} | 30 +- .../operations_client_example_test.go | 55 + ...ed_response_types.go => response_types.go} | 13 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...ze_generated_example_ledger_client_test.go | 206 -- ...enerated_example_operations_client_test.go | 41 - .../zz_generated_models_serde.go | 117 -- .../confluent/armconfluent/CHANGELOG.md | 6 + .../confluent/armconfluent/README.md | 16 +- .../confluent/armconfluent/autorest.md | 2 +- .../confluent/armconfluent/client_factory.go | 59 + ...zz_generated_constants.go => constants.go} | 3 +- .../confluent/armconfluent/go.mod | 22 +- .../confluent/armconfluent/go.sum | 48 +- ...ent.go => marketplaceagreements_client.go} | 43 +- ...rketplaceagreements_client_example_test.go | 119 ++ .../{zz_generated_models.go => models.go} | 11 +- .../confluent/armconfluent/models_serde.go | 622 ++++++ ...ation_client.go => organization_client.go} | 104 +- .../organization_client_example_test.go | 350 ++++ ...nt.go => organizationoperations_client.go} | 32 +- ...anizationoperations_client_example_test.go | 76 + ...ed_response_types.go => response_types.go} | 13 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...ations_client.go => validations_client.go} | 39 +- .../validations_client_example_test.go | 86 + ...ample_marketplaceagreements_client_test.go | 61 - ...erated_example_organization_client_test.go | 187 -- ...mple_organizationoperations_client_test.go | 41 - ...nerated_example_validations_client_test.go | 60 - .../armconfluent/zz_generated_models_serde.go | 205 -- .../armconnectedvmware/CHANGELOG.md | 11 + .../armconnectedvmware/README.md | 18 +- .../armconnectedvmware/autorest.md | 2 +- .../armconnectedvmware/client_factory.go | 112 + .../armconnectedvmware/clusters_client.go | 101 +- .../clusters_client_example_test.go | 159 +- .../armconnectedvmware/constants.go | 2 +- .../armconnectedvmware/datastores_client.go | 101 +- .../datastores_client_example_test.go | 159 +- .../connectedvmware/armconnectedvmware/go.mod | 22 +- .../connectedvmware/armconnectedvmware/go.sum | 48 +- .../armconnectedvmware/guestagents_client.go | 87 +- .../guestagents_client_example_test.go | 85 +- .../armconnectedvmware/hosts_client.go | 101 +- .../hosts_client_example_test.go | 159 +- .../hybrididentitymetadata_client.go | 84 +- ...rididentitymetadata_client_example_test.go | 97 +- .../inventoryitems_client.go | 78 +- .../inventoryitems_client_example_test.go | 79 +- .../machineextensions_client.go | 113 +- .../machineextensions_client_example_test.go | 194 +- .../armconnectedvmware/models.go | 128 +- .../armconnectedvmware/models_serde.go | 398 +--- .../armconnectedvmware/operations_client.go | 29 +- .../operations_client_example_test.go | 221 +- .../armconnectedvmware/polymorphic_helpers.go | 2 +- .../resourcepools_client.go | 105 +- .../resourcepools_client_example_test.go | 159 +- .../armconnectedvmware/response_types.go | 96 +- .../armconnectedvmware/time_rfc3339.go | 2 +- .../armconnectedvmware/vcenters_client.go | 101 +- .../vcenters_client_example_test.go | 184 +- .../virtualmachines_client.go | 205 +- .../virtualmachines_client_example_test.go | 279 ++- .../virtualmachinetemplates_client.go | 111 +- ...ualmachinetemplates_client_example_test.go | 159 +- .../virtualnetworks_client.go | 106 +- .../virtualnetworks_client_example_test.go | 159 +- 240 files changed, 14826 insertions(+), 7087 deletions(-) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/client_factory.go rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_constants.go => constants.go} (98%) rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_locations_client.go => locations_client.go} (81%) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/locations_client_example_test.go rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_memberoperationresults_client.go => memberoperationresults_client.go} (77%) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/memberoperationresults_client_example_test.go rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_members_client.go => members_client.go} (84%) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/members_client_example_test.go rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_models.go => models.go} (98%) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/models_serde.go rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_operations_client.go => operations_client.go} (77%) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/operations_client_example_test.go rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_response_types.go => response_types.go} (91%) rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_skus_client.go => skus_client.go} (73%) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/skus_client_example_test.go rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) rename sdk/resourcemanager/blockchain/armblockchain/{zz_generated_transactionnodes_client.go => transactionnodes_client.go} (84%) create mode 100644 sdk/resourcemanager/blockchain/armblockchain/transactionnodes_client_example_test.go delete mode 100644 sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmemberoperationresults_client_test.go delete mode 100644 sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmembers_client_test.go delete mode 100644 sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_locations_client_test.go delete mode 100644 sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_operations_client_test.go delete mode 100644 sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_skus_client_test.go delete mode 100644 sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_transactionnodes_client_test.go delete mode 100644 sdk/resourcemanager/blockchain/armblockchain/zz_generated_models_serde.go create mode 100644 sdk/resourcemanager/botservice/armbotservice/client_factory.go rename sdk/resourcemanager/changeanalysis/armchangeanalysis/{zz_generated_changes_client.go => changes_client.go} (82%) create mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/changes_client_example_test.go create mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/client_factory.go rename sdk/resourcemanager/changeanalysis/armchangeanalysis/{zz_generated_constants.go => constants.go} (97%) rename sdk/resourcemanager/changeanalysis/armchangeanalysis/{zz_generated_models.go => models.go} (96%) create mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/models_serde.go rename sdk/resourcemanager/changeanalysis/armchangeanalysis/{zz_generated_operations_client.go => operations_client.go} (78%) create mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/operations_client_example_test.go rename sdk/resourcemanager/changeanalysis/armchangeanalysis/{zz_generated_resourcechanges_client.go => resourcechanges_client.go} (78%) create mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/resourcechanges_client_example_test.go rename sdk/resourcemanager/changeanalysis/armchangeanalysis/{zz_generated_response_types.go => response_types.go} (79%) rename sdk/resourcemanager/changeanalysis/armchangeanalysis/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) delete mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_changes_client_test.go delete mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_operations_client_test.go delete mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_resourcechanges_client_test.go delete mode 100644 sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_models_serde.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_capabilities_client.go => capabilities_client.go} (83%) create mode 100644 sdk/resourcemanager/chaos/armchaos/capabilities_client_example_test.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_capabilitytypes_client.go => capabilitytypes_client.go} (81%) create mode 100644 sdk/resourcemanager/chaos/armchaos/capabilitytypes_client_example_test.go create mode 100644 sdk/resourcemanager/chaos/armchaos/client_factory.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_constants.go => constants.go} (98%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_experiments_client.go => experiments_client.go} (86%) create mode 100644 sdk/resourcemanager/chaos/armchaos/experiments_client_example_test.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_models.go => models.go} (97%) create mode 100644 sdk/resourcemanager/chaos/armchaos/models_serde.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_operations_client.go => operations_client.go} (77%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_polymorphic_helpers.go => polymorphic_helpers.go} (97%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_response_types.go => response_types.go} (89%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_targets_client.go => targets_client.go} (83%) create mode 100644 sdk/resourcemanager/chaos/armchaos/targets_client_example_test.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_targettypes_client.go => targettypes_client.go} (81%) create mode 100644 sdk/resourcemanager/chaos/armchaos/targettypes_client_example_test.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/client_factory.go create mode 100644 sdk/resourcemanager/commerce/armcommerce/client_factory.go rename sdk/resourcemanager/commerce/armcommerce/{zz_generated_constants.go => constants.go} (97%) rename sdk/resourcemanager/commerce/armcommerce/{zz_generated_models.go => models.go} (99%) create mode 100644 sdk/resourcemanager/commerce/armcommerce/models_serde.go rename sdk/resourcemanager/commerce/armcommerce/{zz_generated_polymorphic_helpers.go => polymorphic_helpers.go} (97%) rename sdk/resourcemanager/commerce/armcommerce/{zz_generated_ratecard_client.go => ratecard_client.go} (74%) create mode 100644 sdk/resourcemanager/commerce/armcommerce/ratecard_client_example_test.go rename sdk/resourcemanager/commerce/armcommerce/{zz_generated_response_types.go => response_types.go} (91%) rename sdk/resourcemanager/commerce/armcommerce/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) rename sdk/resourcemanager/commerce/armcommerce/{zz_generated_usageaggregates_client.go => usageaggregates_client.go} (78%) delete mode 100644 sdk/resourcemanager/commerce/armcommerce/ze_generated_example_ratecard_client_test.go delete mode 100644 sdk/resourcemanager/commerce/armcommerce/zz_generated_models_serde.go rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{zz_generated_client.go => client.go} (75%) rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{ze_generated_example_confidentialledger_client_test.go => client_example_test.go} (52%) create mode 100644 sdk/resourcemanager/confidentialledger/armconfidentialledger/client_factory.go rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{zz_generated_constants.go => constants.go} (98%) rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{zz_generated_ledger_client.go => ledger_client.go} (85%) create mode 100644 sdk/resourcemanager/confidentialledger/armconfidentialledger/ledger_client_example_test.go rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{zz_generated_models.go => models.go} (97%) create mode 100644 sdk/resourcemanager/confidentialledger/armconfidentialledger/models_serde.go rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{zz_generated_operations_client.go => operations_client.go} (77%) create mode 100644 sdk/resourcemanager/confidentialledger/armconfidentialledger/operations_client_example_test.go rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{zz_generated_response_types.go => response_types.go} (86%) rename sdk/resourcemanager/confidentialledger/armconfidentialledger/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) delete mode 100644 sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_ledger_client_test.go delete mode 100644 sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_operations_client_test.go delete mode 100644 sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_models_serde.go create mode 100644 sdk/resourcemanager/confluent/armconfluent/client_factory.go rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_constants.go => constants.go} (98%) rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_marketplaceagreements_client.go => marketplaceagreements_client.go} (82%) create mode 100644 sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_models.go => models.go} (97%) create mode 100644 sdk/resourcemanager/confluent/armconfluent/models_serde.go rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_organization_client.go => organization_client.go} (86%) create mode 100644 sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_organizationoperations_client.go => organizationoperations_client.go} (78%) create mode 100644 sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_response_types.go => response_types.go} (85%) rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) rename sdk/resourcemanager/confluent/armconfluent/{zz_generated_validations_client.go => validations_client.go} (78%) create mode 100644 sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go delete mode 100644 sdk/resourcemanager/confluent/armconfluent/ze_generated_example_marketplaceagreements_client_test.go delete mode 100644 sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organization_client_test.go delete mode 100644 sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organizationoperations_client_test.go delete mode 100644 sdk/resourcemanager/confluent/armconfluent/ze_generated_example_validations_client_test.go delete mode 100644 sdk/resourcemanager/confluent/armconfluent/zz_generated_models_serde.go create mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go diff --git a/sdk/resourcemanager/blockchain/armblockchain/CHANGELOG.md b/sdk/resourcemanager/blockchain/armblockchain/CHANGELOG.md index dd3ebd376014..c0d2eeecc54d 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/CHANGELOG.md +++ b/sdk/resourcemanager/blockchain/armblockchain/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.5.0, which contains breaking changes. diff --git a/sdk/resourcemanager/blockchain/armblockchain/README.md b/sdk/resourcemanager/blockchain/armblockchain/README.md index fb3905fd3493..541f458259e3 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/README.md +++ b/sdk/resourcemanager/blockchain/armblockchain/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Blockchain modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Blockchain module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armblockchain.NewMembersClient(, cred, nil) +clientFactory, err := armblockchain.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armblockchain.NewMembersClient(, cred, &options) +clientFactory, err := armblockchain.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewMembersClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/blockchain/armblockchain/autorest.md b/sdk/resourcemanager/blockchain/armblockchain/autorest.md index 49a48b09ff3d..dbc5d555da39 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/autorest.md +++ b/sdk/resourcemanager/blockchain/armblockchain/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/blockchain/armblockchain/client_factory.go b/sdk/resourcemanager/blockchain/armblockchain/client_factory.go new file mode 100644 index 000000000000..d23acd7cc156 --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/client_factory.go @@ -0,0 +1,70 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription +// ID is part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewMembersClient() *MembersClient { + subClient, _ := NewMembersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMemberOperationResultsClient() *MemberOperationResultsClient { + subClient, _ := NewMemberOperationResultsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationsClient() *LocationsClient { + subClient, _ := NewLocationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSKUsClient() *SKUsClient { + subClient, _ := NewSKUsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTransactionNodesClient() *TransactionNodesClient { + subClient, _ := NewTransactionNodesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_constants.go b/sdk/resourcemanager/blockchain/armblockchain/constants.go similarity index 98% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_constants.go rename to sdk/resourcemanager/blockchain/armblockchain/constants.go index d63d19cabbe3..82579a585b1d 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_constants.go +++ b/sdk/resourcemanager/blockchain/armblockchain/constants.go @@ -5,12 +5,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain const ( moduleName = "armblockchain" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // BlockchainMemberProvisioningState - Gets or sets the blockchain member provision state. diff --git a/sdk/resourcemanager/blockchain/armblockchain/go.mod b/sdk/resourcemanager/blockchain/armblockchain/go.mod index f9a564155e69..0e91c75ec151 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/go.mod +++ b/sdk/resourcemanager/blockchain/armblockchain/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblock go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/blockchain/armblockchain/go.sum b/sdk/resourcemanager/blockchain/armblockchain/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/go.sum +++ b/sdk/resourcemanager/blockchain/armblockchain/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_locations_client.go b/sdk/resourcemanager/blockchain/armblockchain/locations_client.go similarity index 81% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_locations_client.go rename to sdk/resourcemanager/blockchain/armblockchain/locations_client.go index 6719027d7dad..3614c377e692 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_locations_client.go +++ b/sdk/resourcemanager/blockchain/armblockchain/locations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // LocationsClient contains the methods for the Locations group. // Don't use this type directly, use NewLocationsClient() instead. type LocationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationsClient creates a new instance of LocationsClient with the specified values. -// subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription -// ID is part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription +// ID is part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckNameAvailability - To check whether a resource name is available. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// locationName - Location Name. -// options - LocationsClientCheckNameAvailabilityOptions contains the optional parameters for the LocationsClient.CheckNameAvailability -// method. +// - locationName - Location Name. +// - options - LocationsClientCheckNameAvailabilityOptions contains the optional parameters for the LocationsClient.CheckNameAvailability +// method. func (client *LocationsClient) CheckNameAvailability(ctx context.Context, locationName string, options *LocationsClientCheckNameAvailabilityOptions) (LocationsClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, locationName, options) if err != nil { return LocationsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationsClientCheckNameAvailabilityResponse{}, err } @@ -87,7 +78,7 @@ func (client *LocationsClient) checkNameAvailabilityCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -112,16 +103,17 @@ func (client *LocationsClient) checkNameAvailabilityHandleResponse(resp *http.Re // ListConsortiums - Lists the available consortiums for a subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// locationName - Location Name. -// options - LocationsClientListConsortiumsOptions contains the optional parameters for the LocationsClient.ListConsortiums -// method. +// - locationName - Location Name. +// - options - LocationsClientListConsortiumsOptions contains the optional parameters for the LocationsClient.ListConsortiums +// method. func (client *LocationsClient) ListConsortiums(ctx context.Context, locationName string, options *LocationsClientListConsortiumsOptions) (LocationsClientListConsortiumsResponse, error) { req, err := client.listConsortiumsCreateRequest(ctx, locationName, options) if err != nil { return LocationsClientListConsortiumsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationsClientListConsortiumsResponse{}, err } @@ -142,7 +134,7 @@ func (client *LocationsClient) listConsortiumsCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/blockchain/armblockchain/locations_client_example_test.go b/sdk/resourcemanager/blockchain/armblockchain/locations_client_example_test.go new file mode 100644 index 000000000000..c8d22f507a7e --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/locations_client_example_test.go @@ -0,0 +1,83 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Locations_CheckNameAvailability.json +func ExampleLocationsClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLocationsClient().CheckNameAvailability(ctx, "southeastasia", &armblockchain.LocationsClientCheckNameAvailabilityOptions{NameAvailabilityRequest: &armblockchain.NameAvailabilityRequest{ + Name: to.Ptr("contosemember1"), + Type: to.Ptr("Microsoft.Blockchain/blockchainMembers"), + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NameAvailability = armblockchain.NameAvailability{ + // Message: to.Ptr("A blockchain member named 'contosemember1' is already in use."), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr(armblockchain.NameAvailabilityReasonAlreadyExists), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Locations_ListConsortiums.json +func ExampleLocationsClient_ListConsortiums() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLocationsClient().ListConsortiums(ctx, "southeastasia", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConsortiumCollection = armblockchain.ConsortiumCollection{ + // Value: []*armblockchain.Consortium{ + // { + // Name: to.Ptr("gebiconsortium1"), + // Protocol: to.Ptr(armblockchain.BlockchainProtocolParity), + // }, + // { + // Name: to.Ptr("bwtestpsh"), + // Protocol: to.Ptr(armblockchain.BlockchainProtocolParity), + // }, + // { + // Name: to.Ptr("jackyhsuconsortium"), + // Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), + // }}, + // } +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_memberoperationresults_client.go b/sdk/resourcemanager/blockchain/armblockchain/memberoperationresults_client.go similarity index 77% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_memberoperationresults_client.go rename to sdk/resourcemanager/blockchain/armblockchain/memberoperationresults_client.go index 4bbb0c7a0258..009f0b52a73d 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_memberoperationresults_client.go +++ b/sdk/resourcemanager/blockchain/armblockchain/memberoperationresults_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // MemberOperationResultsClient contains the methods for the BlockchainMemberOperationResults group. // Don't use this type directly, use NewMemberOperationResultsClient() instead. type MemberOperationResultsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMemberOperationResultsClient creates a new instance of MemberOperationResultsClient with the specified values. -// subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription -// ID is part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription +// ID is part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMemberOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MemberOperationResultsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MemberOperationResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MemberOperationResultsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get Async operation result. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// locationName - Location name. -// operationID - Operation Id. -// options - MemberOperationResultsClientGetOptions contains the optional parameters for the MemberOperationResultsClient.Get -// method. +// - locationName - Location name. +// - operationID - Operation Id. +// - options - MemberOperationResultsClientGetOptions contains the optional parameters for the MemberOperationResultsClient.Get +// method. func (client *MemberOperationResultsClient) Get(ctx context.Context, locationName string, operationID string, options *MemberOperationResultsClientGetOptions) (MemberOperationResultsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, locationName, operationID, options) if err != nil { return MemberOperationResultsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MemberOperationResultsClientGetResponse{}, err } @@ -92,7 +83,7 @@ func (client *MemberOperationResultsClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/blockchain/armblockchain/memberoperationresults_client_example_test.go b/sdk/resourcemanager/blockchain/armblockchain/memberoperationresults_client_example_test.go new file mode 100644 index 000000000000..bafe13ab2ec6 --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/memberoperationresults_client_example_test.go @@ -0,0 +1,43 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMemberOperationResults_Get.json +func ExampleMemberOperationResultsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMemberOperationResultsClient().Get(ctx, "southeastasia", "12f4b309-01e3-4fcf-bc0b-1cc034ca03f8", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationResult = armblockchain.OperationResult{ + // Name: to.Ptr("DeleteTransactionNode"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-23T22:28:04.677Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-23T22:34:00.330Z"); return t}()), + // } +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_members_client.go b/sdk/resourcemanager/blockchain/armblockchain/members_client.go similarity index 84% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_members_client.go rename to sdk/resourcemanager/blockchain/armblockchain/members_client.go index f6ad81451987..a57b7b1b3581 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_members_client.go +++ b/sdk/resourcemanager/blockchain/armblockchain/members_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,64 +24,57 @@ import ( // MembersClient contains the methods for the BlockchainMembers group. // Don't use this type directly, use NewMembersClient() instead. type MembersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMembersClient creates a new instance of MembersClient with the specified values. -// subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription -// ID is part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription +// ID is part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMembersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MembersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MembersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MembersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientBeginCreateOptions contains the optional parameters for the MembersClient.BeginCreate method. +// - blockchainMemberName - Blockchain member name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientBeginCreateOptions contains the optional parameters for the MembersClient.BeginCreate method. func (client *MembersClient) BeginCreate(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientBeginCreateOptions) (*runtime.Poller[MembersClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[MembersClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[MembersClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[MembersClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MembersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview func (client *MembersClient) create(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -107,7 +99,7 @@ func (client *MembersClient) createCreateRequest(ctx context.Context, blockchain return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,32 +115,34 @@ func (client *MembersClient) createCreateRequest(ctx context.Context, blockchain // BeginDelete - Delete a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientBeginDeleteOptions contains the optional parameters for the MembersClient.BeginDelete method. +// - blockchainMemberName - Blockchain member name +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientBeginDeleteOptions contains the optional parameters for the MembersClient.BeginDelete method. func (client *MembersClient) BeginDelete(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientBeginDeleteOptions) (*runtime.Poller[MembersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[MembersClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[MembersClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[MembersClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MembersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview func (client *MembersClient) deleteOperation(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -173,7 +167,7 @@ func (client *MembersClient) deleteCreateRequest(ctx context.Context, blockchain return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -185,17 +179,18 @@ func (client *MembersClient) deleteCreateRequest(ctx context.Context, blockchain // Get - Get details about a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientGetOptions contains the optional parameters for the MembersClient.Get method. +// - blockchainMemberName - Blockchain member name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientGetOptions contains the optional parameters for the MembersClient.Get method. func (client *MembersClient) Get(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientGetOptions) (MembersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return MembersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MembersClientGetResponse{}, err } @@ -220,7 +215,7 @@ func (client *MembersClient) getCreateRequest(ctx context.Context, blockchainMem return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -241,11 +236,11 @@ func (client *MembersClient) getHandleResponse(resp *http.Response) (MembersClie } // NewListPager - Lists the blockchain members for a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientListOptions contains the optional parameters for the MembersClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientListOptions contains the optional parameters for the MembersClient.NewListPager method. func (client *MembersClient) NewListPager(resourceGroupName string, options *MembersClientListOptions) *runtime.Pager[MembersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MembersClientListResponse]{ More: func(page MembersClientListResponse) bool { @@ -262,7 +257,7 @@ func (client *MembersClient) NewListPager(resourceGroupName string, options *Mem if err != nil { return MembersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MembersClientListResponse{}, err } @@ -285,7 +280,7 @@ func (client *MembersClient) listCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,17 +302,18 @@ func (client *MembersClient) listHandleResponse(resp *http.Response) (MembersCli // ListAPIKeys - Lists the API keys for a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientListAPIKeysOptions contains the optional parameters for the MembersClient.ListAPIKeys method. +// - blockchainMemberName - Blockchain member name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientListAPIKeysOptions contains the optional parameters for the MembersClient.ListAPIKeys method. func (client *MembersClient) ListAPIKeys(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientListAPIKeysOptions) (MembersClientListAPIKeysResponse, error) { req, err := client.listAPIKeysCreateRequest(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return MembersClientListAPIKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MembersClientListAPIKeysResponse{}, err } @@ -342,7 +338,7 @@ func (client *MembersClient) listAPIKeysCreateRequest(ctx context.Context, block return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -363,9 +359,9 @@ func (client *MembersClient) listAPIKeysHandleResponse(resp *http.Response) (Mem } // NewListAllPager - Lists the blockchain members for a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// options - MembersClientListAllOptions contains the optional parameters for the MembersClient.ListAll method. +// - options - MembersClientListAllOptions contains the optional parameters for the MembersClient.NewListAllPager method. func (client *MembersClient) NewListAllPager(options *MembersClientListAllOptions) *runtime.Pager[MembersClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[MembersClientListAllResponse]{ More: func(page MembersClientListAllResponse) bool { @@ -382,7 +378,7 @@ func (client *MembersClient) NewListAllPager(options *MembersClientListAllOption if err != nil { return MembersClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MembersClientListAllResponse{}, err } @@ -401,7 +397,7 @@ func (client *MembersClient) listAllCreateRequest(ctx context.Context, options * return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -422,13 +418,13 @@ func (client *MembersClient) listAllHandleResponse(resp *http.Response) (Members } // NewListConsortiumMembersPager - Lists the consortium members for a blockchain member. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientListConsortiumMembersOptions contains the optional parameters for the MembersClient.ListConsortiumMembers -// method. +// - blockchainMemberName - Blockchain member name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientListConsortiumMembersOptions contains the optional parameters for the MembersClient.NewListConsortiumMembersPager +// method. func (client *MembersClient) NewListConsortiumMembersPager(blockchainMemberName string, resourceGroupName string, options *MembersClientListConsortiumMembersOptions) *runtime.Pager[MembersClientListConsortiumMembersResponse] { return runtime.NewPager(runtime.PagingHandler[MembersClientListConsortiumMembersResponse]{ More: func(page MembersClientListConsortiumMembersResponse) bool { @@ -445,7 +441,7 @@ func (client *MembersClient) NewListConsortiumMembersPager(blockchainMemberName if err != nil { return MembersClientListConsortiumMembersResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MembersClientListConsortiumMembersResponse{}, err } @@ -472,7 +468,7 @@ func (client *MembersClient) listConsortiumMembersCreateRequest(ctx context.Cont return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -494,18 +490,19 @@ func (client *MembersClient) listConsortiumMembersHandleResponse(resp *http.Resp // ListRegenerateAPIKeys - Regenerate the API keys for a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientListRegenerateAPIKeysOptions contains the optional parameters for the MembersClient.ListRegenerateAPIKeys -// method. +// - blockchainMemberName - Blockchain member name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientListRegenerateAPIKeysOptions contains the optional parameters for the MembersClient.ListRegenerateAPIKeys +// method. func (client *MembersClient) ListRegenerateAPIKeys(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientListRegenerateAPIKeysOptions) (MembersClientListRegenerateAPIKeysResponse, error) { req, err := client.listRegenerateAPIKeysCreateRequest(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return MembersClientListRegenerateAPIKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MembersClientListRegenerateAPIKeysResponse{}, err } @@ -530,7 +527,7 @@ func (client *MembersClient) listRegenerateAPIKeysCreateRequest(ctx context.Cont return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -555,17 +552,18 @@ func (client *MembersClient) listRegenerateAPIKeysHandleResponse(resp *http.Resp // Update - Update a blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - MembersClientUpdateOptions contains the optional parameters for the MembersClient.Update method. +// - blockchainMemberName - Blockchain member name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - MembersClientUpdateOptions contains the optional parameters for the MembersClient.Update method. func (client *MembersClient) Update(ctx context.Context, blockchainMemberName string, resourceGroupName string, options *MembersClientUpdateOptions) (MembersClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, blockchainMemberName, resourceGroupName, options) if err != nil { return MembersClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MembersClientUpdateResponse{}, err } @@ -590,7 +588,7 @@ func (client *MembersClient) updateCreateRequest(ctx context.Context, blockchain return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/blockchain/armblockchain/members_client_example_test.go b/sdk/resourcemanager/blockchain/armblockchain/members_client_example_test.go new file mode 100644 index 000000000000..3efbc8e2181a --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/members_client_example_test.go @@ -0,0 +1,380 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Get.json +func ExampleMembersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMembersClient().Get(ctx, "contosemember1", "mygroup", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Member = armblockchain.Member{ + // Name: to.Ptr("contosemember1"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.MemberProperties{ + // Consortium: to.Ptr("ContoseConsortium"), + // ConsortiumManagementAccountAddress: to.Ptr("0xc40d40dedc353885d3e8393735cf799e4d7fe38c"), + // ConsortiumMemberDisplayName: to.Ptr("contosemember1"), + // ConsortiumRole: to.Ptr("ADMIN"), + // DNS: to.Ptr("contosemember1.blockchain.azure.com"), + // ProvisioningState: to.Ptr(armblockchain.BlockchainMemberProvisioningStateSucceeded), + // PublicKey: to.Ptr("1VhPX4PbNGnE9dOEjgTrw92dltBpKxFQjXWNugcwvl0="), + // RootContractAddress: to.Ptr("0x7407947df2f67142340ca7d1a2c120f0dbfd30e1"), + // UserName: to.Ptr("contosemember1"), + // ValidatorNodesSKU: &armblockchain.MemberNodesSKU{ + // Capacity: to.Ptr[int32](2), + // }, + // Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Create.json +func ExampleMembersClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMembersClient().BeginCreate(ctx, "contosemember1", "mygroup", &armblockchain.MembersClientBeginCreateOptions{BlockchainMember: &armblockchain.Member{ + Location: to.Ptr("southeastasia"), + Properties: &armblockchain.MemberProperties{ + Consortium: to.Ptr("ContoseConsortium"), + ConsortiumManagementAccountPassword: to.Ptr(""), + Password: to.Ptr(""), + ValidatorNodesSKU: &armblockchain.MemberNodesSKU{ + Capacity: to.Ptr[int32](2), + }, + Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Member = armblockchain.Member{ + // Name: to.Ptr("contosemember1"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.MemberProperties{ + // Consortium: to.Ptr("ContoseConsortium"), + // ProvisioningState: to.Ptr(armblockchain.BlockchainMemberProvisioningStateSucceeded), + // UserName: to.Ptr("contosemember1"), + // ValidatorNodesSKU: &armblockchain.MemberNodesSKU{ + // Capacity: to.Ptr[int32](2), + // }, + // Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Delete.json +func ExampleMembersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMembersClient().BeginDelete(ctx, "contosemember1", "mygroup", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Update.json +func ExampleMembersClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMembersClient().Update(ctx, "ContoseMember1", "mygroup", &armblockchain.MembersClientUpdateOptions{BlockchainMember: &armblockchain.MemberUpdate{ + Properties: &armblockchain.MemberPropertiesUpdate{ + Password: to.Ptr(""), + ConsortiumManagementAccountPassword: to.Ptr(""), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Member = armblockchain.Member{ + // Name: to.Ptr("ContoseMember1"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/ContoseMember1"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.MemberProperties{ + // Consortium: to.Ptr("ContoseConsortium"), + // ConsortiumMemberDisplayName: to.Ptr("contosemember1"), + // ConsortiumRole: to.Ptr("ADMIN"), + // ProvisioningState: to.Ptr(armblockchain.BlockchainMemberProvisioningStateSucceeded), + // UserName: to.Ptr("testuser1"), + // ValidatorNodesSKU: &armblockchain.MemberNodesSKU{ + // Capacity: to.Ptr[int32](2), + // }, + // Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_List.json +func ExampleMembersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMembersClient().NewListPager("mygroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.MemberCollection = armblockchain.MemberCollection{ + // Value: []*armblockchain.Member{ + // { + // Name: to.Ptr("contosemember1"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.MemberProperties{ + // Consortium: to.Ptr("ContoseConsortium"), + // ConsortiumMemberDisplayName: to.Ptr("contosemember1"), + // ConsortiumRole: to.Ptr("ADMIN"), + // DNS: to.Ptr("contosemember1.blockchain.azure.com"), + // ProvisioningState: to.Ptr(armblockchain.BlockchainMemberProvisioningStateSucceeded), + // PublicKey: to.Ptr("1VhPX4PbNGnE9dOEjgTrw92dltBpKxFQjXWNugcwvl0="), + // RootContractAddress: to.Ptr("0x7407947df2f67142340ca7d1a2c120f0dbfd30e1"), + // UserName: to.Ptr("contosemember1"), + // ValidatorNodesSKU: &armblockchain.MemberNodesSKU{ + // Capacity: to.Ptr[int32](2), + // }, + // Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_ListAll.json +func ExampleMembersClient_NewListAllPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMembersClient().NewListAllPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.MemberCollection = armblockchain.MemberCollection{ + // Value: []*armblockchain.Member{ + // { + // Name: to.Ptr("contosemember1"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.MemberProperties{ + // Consortium: to.Ptr("ContoseConsortium"), + // ConsortiumMemberDisplayName: to.Ptr("contosemember1"), + // ConsortiumRole: to.Ptr("ADMIN"), + // DNS: to.Ptr("contosemember1.blockchain.azure.com"), + // ProvisioningState: to.Ptr(armblockchain.BlockchainMemberProvisioningStateSucceeded), + // PublicKey: to.Ptr("1VhPX4PbNGnE9dOEjgTrw92dltBpKxFQjXWNugcwvl0="), + // RootContractAddress: to.Ptr("0x7407947df2f67142340ca7d1a2c120f0dbfd30e1"), + // UserName: to.Ptr("contosemember1"), + // ValidatorNodesSKU: &armblockchain.MemberNodesSKU{ + // Capacity: to.Ptr[int32](2), + // }, + // Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_ListConsortiumMembers.json +func ExampleMembersClient_NewListConsortiumMembersPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMembersClient().NewListConsortiumMembersPager("contosemember1", "mygroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ConsortiumMemberCollection = armblockchain.ConsortiumMemberCollection{ + // Value: []*armblockchain.ConsortiumMember{ + // { + // Name: to.Ptr("contosemember1"), + // DateModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-23T22:34:00.330Z"); return t}()), + // DisplayName: to.Ptr("Contose member 1"), + // JoinDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-23T22:34:00.330Z"); return t}()), + // Role: to.Ptr("Member"), + // Status: to.Ptr("Ready"), + // SubscriptionID: to.Ptr("51766542-3ed7-4a72-a187-0c8ab644ddab"), + // }, + // { + // Name: to.Ptr(""), + // DateModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-23T22:34:00.330Z"); return t}()), + // Role: to.Ptr("ADMIN"), + // Status: to.Ptr("Invited"), + // SubscriptionID: to.Ptr("02bf808a-5446-4e54-aea8-39723aaa05e7"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_ListApiKeys.json +func ExampleMembersClient_ListAPIKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMembersClient().ListAPIKeys(ctx, "contosemember1", "mygroup", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.APIKeyCollection = armblockchain.APIKeyCollection{ + // Keys: []*armblockchain.APIKey{ + // { + // KeyName: to.Ptr("key1"), + // Value: to.Ptr("-EnIUzu29xj60xPJmstyCURo"), + // }, + // { + // KeyName: to.Ptr("key2"), + // Value: to.Ptr("I8P-q4u_WDuCZUBYXnJ3yYX7"), + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_ListRegenerateApiKeys.json +func ExampleMembersClient_ListRegenerateAPIKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMembersClient().ListRegenerateAPIKeys(ctx, "contosemember1", "mygroup", &armblockchain.MembersClientListRegenerateAPIKeysOptions{APIKey: &armblockchain.APIKey{ + KeyName: to.Ptr("key1"), + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.APIKeyCollection = armblockchain.APIKeyCollection{ + // Keys: []*armblockchain.APIKey{ + // { + // KeyName: to.Ptr("key1"), + // Value: to.Ptr("-EnIUzu29xj60xPJmstyCURo"), + // }, + // { + // KeyName: to.Ptr("key2"), + // Value: to.Ptr("-EHio4yRJLxajDaxRNaoD7cZ"), + // }}, + // } +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_models.go b/sdk/resourcemanager/blockchain/armblockchain/models.go similarity index 98% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_models.go rename to sdk/resourcemanager/blockchain/armblockchain/models.go index fd34d75b39d7..85db513b9204 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_models.go +++ b/sdk/resourcemanager/blockchain/armblockchain/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -234,18 +235,18 @@ type MembersClientListAPIKeysOptions struct { // placeholder for future optional parameters } -// MembersClientListAllOptions contains the optional parameters for the MembersClient.ListAll method. +// MembersClientListAllOptions contains the optional parameters for the MembersClient.NewListAllPager method. type MembersClientListAllOptions struct { // placeholder for future optional parameters } -// MembersClientListConsortiumMembersOptions contains the optional parameters for the MembersClient.ListConsortiumMembers +// MembersClientListConsortiumMembersOptions contains the optional parameters for the MembersClient.NewListConsortiumMembersPager // method. type MembersClientListConsortiumMembersOptions struct { // placeholder for future optional parameters } -// MembersClientListOptions contains the optional parameters for the MembersClient.List method. +// MembersClientListOptions contains the optional parameters for the MembersClient.NewListPager method. type MembersClientListOptions struct { // placeholder for future optional parameters } @@ -296,7 +297,7 @@ type OperationResult struct { StartTime *time.Time `json:"startTime,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -505,7 +506,7 @@ type TransactionNodesClientListAPIKeysOptions struct { // placeholder for future optional parameters } -// TransactionNodesClientListOptions contains the optional parameters for the TransactionNodesClient.List method. +// TransactionNodesClientListOptions contains the optional parameters for the TransactionNodesClient.NewListPager method. type TransactionNodesClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/blockchain/armblockchain/models_serde.go b/sdk/resourcemanager/blockchain/armblockchain/models_serde.go new file mode 100644 index 000000000000..c89c1c867cf5 --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/models_serde.go @@ -0,0 +1,1119 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type APIKey. +func (a APIKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyName", a.KeyName) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIKey. +func (a *APIKey) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyName": + err = unpopulate(val, "KeyName", &a.KeyName) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIKeyCollection. +func (a APIKeyCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keys", a.Keys) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIKeyCollection. +func (a *APIKeyCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keys": + err = unpopulate(val, "Keys", &a.Keys) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Consortium. +func (c Consortium) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "protocol", c.Protocol) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Consortium. +func (c *Consortium) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "protocol": + err = unpopulate(val, "Protocol", &c.Protocol) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConsortiumCollection. +func (c ConsortiumCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConsortiumCollection. +func (c *ConsortiumCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConsortiumMember. +func (c ConsortiumMember) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "dateModified", c.DateModified) + populate(objectMap, "displayName", c.DisplayName) + populateTimeRFC3339(objectMap, "joinDate", c.JoinDate) + populate(objectMap, "name", c.Name) + populate(objectMap, "role", c.Role) + populate(objectMap, "status", c.Status) + populate(objectMap, "subscriptionId", c.SubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConsortiumMember. +func (c *ConsortiumMember) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dateModified": + err = unpopulateTimeRFC3339(val, "DateModified", &c.DateModified) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "joinDate": + err = unpopulateTimeRFC3339(val, "JoinDate", &c.JoinDate) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "Role", &c.Role) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &c.SubscriptionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConsortiumMemberCollection. +func (c ConsortiumMemberCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConsortiumMemberCollection. +func (c *ConsortiumMemberCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FirewallRule. +func (f FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endIpAddress", f.EndIPAddress) + populate(objectMap, "ruleName", f.RuleName) + populate(objectMap, "startIpAddress", f.StartIPAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FirewallRule. +func (f *FirewallRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endIpAddress": + err = unpopulate(val, "EndIPAddress", &f.EndIPAddress) + delete(rawMsg, key) + case "ruleName": + err = unpopulate(val, "RuleName", &f.RuleName) + delete(rawMsg, key) + case "startIpAddress": + err = unpopulate(val, "StartIPAddress", &f.StartIPAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Member. +func (m Member) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "location", m.Location) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "sku", m.SKU) + populate(objectMap, "tags", m.Tags) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Member. +func (m *Member) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &m.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MemberCollection. +func (m MemberCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemberCollection. +func (m *MemberCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MemberNodesSKU. +func (m MemberNodesSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", m.Capacity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemberNodesSKU. +func (m *MemberNodesSKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacity": + err = unpopulate(val, "Capacity", &m.Capacity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MemberProperties. +func (m MemberProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consortium", m.Consortium) + populate(objectMap, "consortiumManagementAccountAddress", m.ConsortiumManagementAccountAddress) + populate(objectMap, "consortiumManagementAccountPassword", m.ConsortiumManagementAccountPassword) + populate(objectMap, "consortiumMemberDisplayName", m.ConsortiumMemberDisplayName) + populate(objectMap, "consortiumRole", m.ConsortiumRole) + populate(objectMap, "dns", m.DNS) + populate(objectMap, "firewallRules", m.FirewallRules) + populate(objectMap, "password", m.Password) + populate(objectMap, "protocol", m.Protocol) + populate(objectMap, "provisioningState", m.ProvisioningState) + populate(objectMap, "publicKey", m.PublicKey) + populate(objectMap, "rootContractAddress", m.RootContractAddress) + populate(objectMap, "userName", m.UserName) + populate(objectMap, "validatorNodesSku", m.ValidatorNodesSKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemberProperties. +func (m *MemberProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "consortium": + err = unpopulate(val, "Consortium", &m.Consortium) + delete(rawMsg, key) + case "consortiumManagementAccountAddress": + err = unpopulate(val, "ConsortiumManagementAccountAddress", &m.ConsortiumManagementAccountAddress) + delete(rawMsg, key) + case "consortiumManagementAccountPassword": + err = unpopulate(val, "ConsortiumManagementAccountPassword", &m.ConsortiumManagementAccountPassword) + delete(rawMsg, key) + case "consortiumMemberDisplayName": + err = unpopulate(val, "ConsortiumMemberDisplayName", &m.ConsortiumMemberDisplayName) + delete(rawMsg, key) + case "consortiumRole": + err = unpopulate(val, "ConsortiumRole", &m.ConsortiumRole) + delete(rawMsg, key) + case "dns": + err = unpopulate(val, "DNS", &m.DNS) + delete(rawMsg, key) + case "firewallRules": + err = unpopulate(val, "FirewallRules", &m.FirewallRules) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &m.Password) + delete(rawMsg, key) + case "protocol": + err = unpopulate(val, "Protocol", &m.Protocol) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) + delete(rawMsg, key) + case "publicKey": + err = unpopulate(val, "PublicKey", &m.PublicKey) + delete(rawMsg, key) + case "rootContractAddress": + err = unpopulate(val, "RootContractAddress", &m.RootContractAddress) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &m.UserName) + delete(rawMsg, key) + case "validatorNodesSku": + err = unpopulate(val, "ValidatorNodesSKU", &m.ValidatorNodesSKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MemberPropertiesUpdate. +func (m MemberPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consortiumManagementAccountPassword", m.ConsortiumManagementAccountPassword) + populate(objectMap, "firewallRules", m.FirewallRules) + populate(objectMap, "password", m.Password) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemberPropertiesUpdate. +func (m *MemberPropertiesUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "consortiumManagementAccountPassword": + err = unpopulate(val, "ConsortiumManagementAccountPassword", &m.ConsortiumManagementAccountPassword) + delete(rawMsg, key) + case "firewallRules": + err = unpopulate(val, "FirewallRules", &m.FirewallRules) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &m.Password) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MemberUpdate. +func (m MemberUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "tags", m.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemberUpdate. +func (m *MemberUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NameAvailability. +func (n NameAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", n.Message) + populate(objectMap, "nameAvailable", n.NameAvailable) + populate(objectMap, "reason", n.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NameAvailability. +func (n *NameAvailability) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &n.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &n.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &n.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NameAvailabilityRequest. +func (n NameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", n.Name) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NameAvailabilityRequest. +func (n *NameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationResult. +func (o OperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populate(objectMap, "name", o.Name) + populateTimeRFC3339(objectMap, "startTime", o.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResult. +func (o *OperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperation. +func (r ResourceProviderOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", r.Display) + populate(objectMap, "isDataAction", r.IsDataAction) + populate(objectMap, "name", r.Name) + populate(objectMap, "origin", r.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperation. +func (r *ResourceProviderOperation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &r.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &r.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &r.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationCollection. +func (r ResourceProviderOperationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationCollection. +func (r *ResourceProviderOperationCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationDisplay. +func (r ResourceProviderOperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", r.Description) + populate(objectMap, "operation", r.Operation) + populate(objectMap, "provider", r.Provider) + populate(objectMap, "resource", r.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDisplay. +func (r *ResourceProviderOperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &r.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &r.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &r.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceTypeSKU. +func (r ResourceTypeSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceType", r.ResourceType) + populate(objectMap, "skus", r.SKUs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceTypeSKU. +func (r *ResourceTypeSKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) + delete(rawMsg, key) + case "skus": + err = unpopulate(val, "SKUs", &r.SKUs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceTypeSKUCollection. +func (r ResourceTypeSKUCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceTypeSKUCollection. +func (r *ResourceTypeSKUCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKUSetting. +func (s SKUSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "locations", s.Locations) + populate(objectMap, "name", s.Name) + populate(objectMap, "requiredFeatures", s.RequiredFeatures) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUSetting. +func (s *SKUSetting) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "locations": + err = unpopulate(val, "Locations", &s.Locations) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "requiredFeatures": + err = unpopulate(val, "RequiredFeatures", &s.RequiredFeatures) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionNode. +func (t TransactionNode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionNode. +func (t *TransactionNode) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionNodeCollection. +func (t TransactionNodeCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionNodeCollection. +func (t *TransactionNodeCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionNodeProperties. +func (t TransactionNodeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dns", t.DNS) + populate(objectMap, "firewallRules", t.FirewallRules) + populate(objectMap, "password", t.Password) + populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "publicKey", t.PublicKey) + populate(objectMap, "userName", t.UserName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionNodeProperties. +func (t *TransactionNodeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dns": + err = unpopulate(val, "DNS", &t.DNS) + delete(rawMsg, key) + case "firewallRules": + err = unpopulate(val, "FirewallRules", &t.FirewallRules) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &t.Password) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) + delete(rawMsg, key) + case "publicKey": + err = unpopulate(val, "PublicKey", &t.PublicKey) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &t.UserName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionNodePropertiesUpdate. +func (t TransactionNodePropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "firewallRules", t.FirewallRules) + populate(objectMap, "password", t.Password) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionNodePropertiesUpdate. +func (t *TransactionNodePropertiesUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "firewallRules": + err = unpopulate(val, "FirewallRules", &t.FirewallRules) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &t.Password) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransactionNodeUpdate. +func (t TransactionNodeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionNodeUpdate. +func (t *TransactionNodeUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_operations_client.go b/sdk/resourcemanager/blockchain/armblockchain/operations_client.go similarity index 77% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_operations_client.go rename to sdk/resourcemanager/blockchain/armblockchain/operations_client.go index 9e50d02857bf..76d7ffa00661 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_operations_client.go +++ b/sdk/resourcemanager/blockchain/armblockchain/operations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists the available operations of Microsoft.Blockchain resource provider. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Blockchain/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/blockchain/armblockchain/operations_client_example_test.go b/sdk/resourcemanager/blockchain/armblockchain/operations_client_example_test.go new file mode 100644 index 000000000000..61dc2514dc74 --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/operations_client_example_test.go @@ -0,0 +1,189 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ResourceProviderOperationCollection = armblockchain.ResourceProviderOperationCollection{ + // Value: []*armblockchain.ResourceProviderOperation{ + // { + // Name: to.Ptr("Microsoft.Blockchain/register/action"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Registers the subscription for the Blockchain Resource Provider."), + // Operation: to.Ptr("Register the Blockchain Resource Provider"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Resource Provider"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/read"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Gets or Lists existing Blockchain Member(s)."), + // Operation: to.Ptr("Get or List Blockchain Member(s)"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Members"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/write"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Creates or Updates a Blockchain Member."), + // Operation: to.Ptr("Create or Update Blockchain Member"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Members"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/delete"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Deletes an existing Blockchain Member."), + // Operation: to.Ptr("Delete Blockchain Member"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Members"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes/read"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Gets or Lists existing Blockchain Member Transaction Node(s)."), + // Operation: to.Ptr("Get or List Blockchain Member Transaction Node(s)"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Member Transaction Nodes"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes/write"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Creates or Updates a Blockchain Member Transaction Node."), + // Operation: to.Ptr("Create or Update Blockchain Member Transaction Node"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Member Transaction Nodes"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes/delete"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Deletes an existing Blockchain Member Transaction Node."), + // Operation: to.Ptr("Delete Blockchain Member Transaction Node"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Member Transaction Nodes"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes/connect/action"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Connects to a Blockchain Member Transaction Node."), + // Operation: to.Ptr("Connect Blockchain Member Transaction Node"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Blockchain Member Transaction Nodes"), + // }, + // IsDataAction: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/locations/blockchainMemberOperationResults/read"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Gets the Operation Results of Blockchain Members."), + // Operation: to.Ptr("Get Blockchain Member Operation Results"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Locations"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/locations/checkNameAvailability/action"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Checks that resource name is valid and is not in use."), + // Operation: to.Ptr("Check Name Availability"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Locations"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/operations/read"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("List all Operations in Microsoft Blockchain Resource Provider."), + // Operation: to.Ptr("List all Operations"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("Operations"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/providers/Microsoft.Insights/logDefinitions/read"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Gets the available logs for Microsoft Blockchain"), + // Operation: to.Ptr("Read Microsoft Blockchain log definitions"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("The log definition of Microsoft Blockchain"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Gets the diagnostic setting for the resource"), + // Operation: to.Ptr("Read diagnostic setting"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("The display resource of diagnostic settings of Microsoft Blockchain"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.Blockchain/blockchainMembers/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armblockchain.ResourceProviderOperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource"), + // Operation: to.Ptr("Write diagnostic setting"), + // Provider: to.Ptr("Microsoft Blockchain"), + // Resource: to.Ptr("The display resource of diagnostic settings of Microsoft Blockchain"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("system"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_response_types.go b/sdk/resourcemanager/blockchain/armblockchain/response_types.go similarity index 91% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_response_types.go rename to sdk/resourcemanager/blockchain/armblockchain/response_types.go index 69040a3bebc6..33fc09bb702a 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_response_types.go +++ b/sdk/resourcemanager/blockchain/armblockchain/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -23,12 +24,12 @@ type MemberOperationResultsClientGetResponse struct { OperationResult } -// MembersClientCreateResponse contains the response from method MembersClient.Create. +// MembersClientCreateResponse contains the response from method MembersClient.BeginCreate. type MembersClientCreateResponse struct { Member } -// MembersClientDeleteResponse contains the response from method MembersClient.Delete. +// MembersClientDeleteResponse contains the response from method MembersClient.BeginDelete. type MembersClientDeleteResponse struct { // placeholder for future response values } @@ -43,12 +44,12 @@ type MembersClientListAPIKeysResponse struct { APIKeyCollection } -// MembersClientListAllResponse contains the response from method MembersClient.ListAll. +// MembersClientListAllResponse contains the response from method MembersClient.NewListAllPager. type MembersClientListAllResponse struct { MemberCollection } -// MembersClientListConsortiumMembersResponse contains the response from method MembersClient.ListConsortiumMembers. +// MembersClientListConsortiumMembersResponse contains the response from method MembersClient.NewListConsortiumMembersPager. type MembersClientListConsortiumMembersResponse struct { ConsortiumMemberCollection } @@ -58,7 +59,7 @@ type MembersClientListRegenerateAPIKeysResponse struct { APIKeyCollection } -// MembersClientListResponse contains the response from method MembersClient.List. +// MembersClientListResponse contains the response from method MembersClient.NewListPager. type MembersClientListResponse struct { MemberCollection } @@ -68,7 +69,7 @@ type MembersClientUpdateResponse struct { Member } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { ResourceProviderOperationCollection } @@ -78,12 +79,12 @@ type SKUsClientListResponse struct { ResourceTypeSKUCollection } -// TransactionNodesClientCreateResponse contains the response from method TransactionNodesClient.Create. +// TransactionNodesClientCreateResponse contains the response from method TransactionNodesClient.BeginCreate. type TransactionNodesClientCreateResponse struct { TransactionNode } -// TransactionNodesClientDeleteResponse contains the response from method TransactionNodesClient.Delete. +// TransactionNodesClientDeleteResponse contains the response from method TransactionNodesClient.BeginDelete. type TransactionNodesClientDeleteResponse struct { // placeholder for future response values } @@ -103,7 +104,7 @@ type TransactionNodesClientListRegenerateAPIKeysResponse struct { APIKeyCollection } -// TransactionNodesClientListResponse contains the response from method TransactionNodesClient.List. +// TransactionNodesClientListResponse contains the response from method TransactionNodesClient.NewListPager. type TransactionNodesClientListResponse struct { TransactionNodeCollection } diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_skus_client.go b/sdk/resourcemanager/blockchain/armblockchain/skus_client.go similarity index 73% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_skus_client.go rename to sdk/resourcemanager/blockchain/armblockchain/skus_client.go index 5aa805eed1f2..5aa7c7e580b0 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_skus_client.go +++ b/sdk/resourcemanager/blockchain/armblockchain/skus_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,46 +24,38 @@ import ( // SKUsClient contains the methods for the SKUs group. // Don't use this type directly, use NewSKUsClient() instead. type SKUsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSKUsClient creates a new instance of SKUsClient with the specified values. -// subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription -// ID is part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription +// ID is part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SKUsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SKUsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Lists the Skus of the resource type. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// options - SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +// - options - SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. func (client *SKUsClient) List(ctx context.Context, options *SKUsClientListOptions) (SKUsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return SKUsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SKUsClientListResponse{}, err } @@ -81,7 +72,7 @@ func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsCl return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/blockchain/armblockchain/skus_client_example_test.go b/sdk/resourcemanager/blockchain/armblockchain/skus_client_example_test.go new file mode 100644 index 000000000000..0d4647602ab6 --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/skus_client_example_test.go @@ -0,0 +1,61 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Skus_List.json +func ExampleSKUsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSKUsClient().List(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourceTypeSKUCollection = armblockchain.ResourceTypeSKUCollection{ + // Value: []*armblockchain.ResourceTypeSKU{ + // { + // ResourceType: to.Ptr("blockchainMembers"), + // SKUs: []*armblockchain.SKUSetting{ + // { + // Name: to.Ptr("B0"), + // Locations: []*string{ + // to.Ptr("SoutheastAsia")}, + // RequiredFeatures: []*string{ + // to.Ptr("Microsoft.Blockchain/privatePreviewAccess")}, + // Tier: to.Ptr("Basic"), + // }, + // { + // Name: to.Ptr("S0"), + // Locations: []*string{ + // to.Ptr("SoutheastAsia")}, + // RequiredFeatures: []*string{ + // to.Ptr("Microsoft.Blockchain/privatePreviewAccess")}, + // Tier: to.Ptr("Standard"), + // }}, + // }}, + // } +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_time_rfc3339.go b/sdk/resourcemanager/blockchain/armblockchain/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/blockchain/armblockchain/time_rfc3339.go index dc437dce8d47..6aeeec844b4c 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/blockchain/armblockchain/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_transactionnodes_client.go b/sdk/resourcemanager/blockchain/armblockchain/transactionnodes_client.go similarity index 84% rename from sdk/resourcemanager/blockchain/armblockchain/zz_generated_transactionnodes_client.go rename to sdk/resourcemanager/blockchain/armblockchain/transactionnodes_client.go index 92f1fbb8d826..d6614a74732a 100644 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_transactionnodes_client.go +++ b/sdk/resourcemanager/blockchain/armblockchain/transactionnodes_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armblockchain @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,66 +24,59 @@ import ( // TransactionNodesClient contains the methods for the TransactionNodes group. // Don't use this type directly, use NewTransactionNodesClient() instead. type TransactionNodesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTransactionNodesClient creates a new instance of TransactionNodesClient with the specified values. -// subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription -// ID is part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription +// ID is part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTransactionNodesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TransactionNodesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TransactionNodesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TransactionNodesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create or update the transaction node. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// transactionNodeName - Transaction node name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - TransactionNodesClientBeginCreateOptions contains the optional parameters for the TransactionNodesClient.BeginCreate -// method. +// - blockchainMemberName - Blockchain member name. +// - transactionNodeName - Transaction node name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - TransactionNodesClientBeginCreateOptions contains the optional parameters for the TransactionNodesClient.BeginCreate +// method. func (client *TransactionNodesClient) BeginCreate(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientBeginCreateOptions) (*runtime.Poller[TransactionNodesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[TransactionNodesClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[TransactionNodesClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[TransactionNodesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TransactionNodesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create or update the transaction node. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview func (client *TransactionNodesClient) create(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -113,7 +105,7 @@ func (client *TransactionNodesClient) createCreateRequest(ctx context.Context, b return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -129,34 +121,36 @@ func (client *TransactionNodesClient) createCreateRequest(ctx context.Context, b // BeginDelete - Delete the transaction node. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// transactionNodeName - Transaction node name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - TransactionNodesClientBeginDeleteOptions contains the optional parameters for the TransactionNodesClient.BeginDelete -// method. +// - blockchainMemberName - Blockchain member name. +// - transactionNodeName - Transaction node name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - TransactionNodesClientBeginDeleteOptions contains the optional parameters for the TransactionNodesClient.BeginDelete +// method. func (client *TransactionNodesClient) BeginDelete(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientBeginDeleteOptions) (*runtime.Poller[TransactionNodesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller[TransactionNodesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[TransactionNodesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[TransactionNodesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TransactionNodesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete the transaction node. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview func (client *TransactionNodesClient) deleteOperation(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +179,7 @@ func (client *TransactionNodesClient) deleteCreateRequest(ctx context.Context, b return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -197,18 +191,19 @@ func (client *TransactionNodesClient) deleteCreateRequest(ctx context.Context, b // Get - Get the details of the transaction node. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// transactionNodeName - Transaction node name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - TransactionNodesClientGetOptions contains the optional parameters for the TransactionNodesClient.Get method. +// - blockchainMemberName - Blockchain member name. +// - transactionNodeName - Transaction node name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - TransactionNodesClientGetOptions contains the optional parameters for the TransactionNodesClient.Get method. func (client *TransactionNodesClient) Get(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientGetOptions) (TransactionNodesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return TransactionNodesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransactionNodesClientGetResponse{}, err } @@ -237,7 +232,7 @@ func (client *TransactionNodesClient) getCreateRequest(ctx context.Context, bloc return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,12 +253,13 @@ func (client *TransactionNodesClient) getHandleResponse(resp *http.Response) (Tr } // NewListPager - Lists the transaction nodes for a blockchain member. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - TransactionNodesClientListOptions contains the optional parameters for the TransactionNodesClient.List method. +// - blockchainMemberName - Blockchain member name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - TransactionNodesClientListOptions contains the optional parameters for the TransactionNodesClient.NewListPager +// method. func (client *TransactionNodesClient) NewListPager(blockchainMemberName string, resourceGroupName string, options *TransactionNodesClientListOptions) *runtime.Pager[TransactionNodesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TransactionNodesClientListResponse]{ More: func(page TransactionNodesClientListResponse) bool { @@ -280,7 +276,7 @@ func (client *TransactionNodesClient) NewListPager(blockchainMemberName string, if err != nil { return TransactionNodesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransactionNodesClientListResponse{}, err } @@ -307,7 +303,7 @@ func (client *TransactionNodesClient) listCreateRequest(ctx context.Context, blo return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -329,19 +325,20 @@ func (client *TransactionNodesClient) listHandleResponse(resp *http.Response) (T // ListAPIKeys - List the API keys for the transaction node. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// transactionNodeName - Transaction node name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - TransactionNodesClientListAPIKeysOptions contains the optional parameters for the TransactionNodesClient.ListAPIKeys -// method. +// - blockchainMemberName - Blockchain member name. +// - transactionNodeName - Transaction node name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - TransactionNodesClientListAPIKeysOptions contains the optional parameters for the TransactionNodesClient.ListAPIKeys +// method. func (client *TransactionNodesClient) ListAPIKeys(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientListAPIKeysOptions) (TransactionNodesClientListAPIKeysResponse, error) { req, err := client.listAPIKeysCreateRequest(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return TransactionNodesClientListAPIKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransactionNodesClientListAPIKeysResponse{}, err } @@ -370,7 +367,7 @@ func (client *TransactionNodesClient) listAPIKeysCreateRequest(ctx context.Conte return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -392,19 +389,20 @@ func (client *TransactionNodesClient) listAPIKeysHandleResponse(resp *http.Respo // ListRegenerateAPIKeys - Regenerate the API keys for the blockchain member. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// transactionNodeName - Transaction node name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - TransactionNodesClientListRegenerateAPIKeysOptions contains the optional parameters for the TransactionNodesClient.ListRegenerateAPIKeys -// method. +// - blockchainMemberName - Blockchain member name. +// - transactionNodeName - Transaction node name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - TransactionNodesClientListRegenerateAPIKeysOptions contains the optional parameters for the TransactionNodesClient.ListRegenerateAPIKeys +// method. func (client *TransactionNodesClient) ListRegenerateAPIKeys(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientListRegenerateAPIKeysOptions) (TransactionNodesClientListRegenerateAPIKeysResponse, error) { req, err := client.listRegenerateAPIKeysCreateRequest(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return TransactionNodesClientListRegenerateAPIKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransactionNodesClientListRegenerateAPIKeysResponse{}, err } @@ -433,7 +431,7 @@ func (client *TransactionNodesClient) listRegenerateAPIKeysCreateRequest(ctx con return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -458,18 +456,19 @@ func (client *TransactionNodesClient) listRegenerateAPIKeysHandleResponse(resp * // Update - Update the transaction node. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-06-01-preview -// blockchainMemberName - Blockchain member name. -// transactionNodeName - Transaction node name. -// resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure -// Resource Manager API or the portal. -// options - TransactionNodesClientUpdateOptions contains the optional parameters for the TransactionNodesClient.Update method. +// - blockchainMemberName - Blockchain member name. +// - transactionNodeName - Transaction node name. +// - resourceGroupName - The name of the resource group that contains the resource. You can obtain this value from the Azure +// Resource Manager API or the portal. +// - options - TransactionNodesClientUpdateOptions contains the optional parameters for the TransactionNodesClient.Update method. func (client *TransactionNodesClient) Update(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, options *TransactionNodesClientUpdateOptions) (TransactionNodesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, options) if err != nil { return TransactionNodesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TransactionNodesClientUpdateResponse{}, err } @@ -498,7 +497,7 @@ func (client *TransactionNodesClient) updateCreateRequest(ctx context.Context, b return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/blockchain/armblockchain/transactionnodes_client_example_test.go b/sdk/resourcemanager/blockchain/armblockchain/transactionnodes_client_example_test.go new file mode 100644 index 000000000000..26cb820dbec8 --- /dev/null +++ b/sdk/resourcemanager/blockchain/armblockchain/transactionnodes_client_example_test.go @@ -0,0 +1,254 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armblockchain_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Get.json +func ExampleTransactionNodesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransactionNodesClient().Get(ctx, "contosemember1", "txnode2", "mygroup", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransactionNode = armblockchain.TransactionNode{ + // Name: to.Ptr("txnode2"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1/transactionNodes/txnode2"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.TransactionNodeProperties{ + // DNS: to.Ptr("txnode2-contosemember1.blockchain.ppe.azure-int.net"), + // ProvisioningState: to.Ptr(armblockchain.NodeProvisioningStateSucceeded), + // PublicKey: to.Ptr("h7Q10I/1dLK/hzX8FkVrfl03D/aX8jW3YNoxJ/n4vkY="), + // UserName: to.Ptr("txnode2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Create.json +func ExampleTransactionNodesClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTransactionNodesClient().BeginCreate(ctx, "contosemember1", "txnode2", "mygroup", &armblockchain.TransactionNodesClientBeginCreateOptions{TransactionNode: &armblockchain.TransactionNode{ + Location: to.Ptr("southeastasia"), + Properties: &armblockchain.TransactionNodeProperties{ + Password: to.Ptr(""), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransactionNode = armblockchain.TransactionNode{ + // Name: to.Ptr("txnode2"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1/transactionNodes/txnode2"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.TransactionNodeProperties{ + // ProvisioningState: to.Ptr(armblockchain.NodeProvisioningStateSucceeded), + // UserName: to.Ptr("txnode2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Delete.json +func ExampleTransactionNodesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTransactionNodesClient().BeginDelete(ctx, "contosemember1", "txNode2", "mygroup", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Update.json +func ExampleTransactionNodesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransactionNodesClient().Update(ctx, "contosemember1", "txnode2", "mygroup", &armblockchain.TransactionNodesClientUpdateOptions{TransactionNode: &armblockchain.TransactionNodeUpdate{ + Properties: &armblockchain.TransactionNodePropertiesUpdate{ + Password: to.Ptr(""), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TransactionNode = armblockchain.TransactionNode{ + // Name: to.Ptr("txnode2"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1/transactionNodes/txnode2"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.TransactionNodeProperties{ + // DNS: to.Ptr("txnode1-contosemember1.blockchain.azure.com"), + // ProvisioningState: to.Ptr(armblockchain.NodeProvisioningStateSucceeded), + // PublicKey: to.Ptr("DbRYTorBtY7rZfNfByUQpdC+hD3k/0lfA7+UnH4ovWM="), + // UserName: to.Ptr("txnode2"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_List.json +func ExampleTransactionNodesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTransactionNodesClient().NewListPager("contosemember1", "mygroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TransactionNodeCollection = armblockchain.TransactionNodeCollection{ + // Value: []*armblockchain.TransactionNode{ + // { + // Name: to.Ptr("txnode2"), + // Type: to.Ptr("Microsoft.Blockchain/blockchainMembers/transactionNodes"), + // ID: to.Ptr("/subscriptions/51766542-3ed7-4a72-a187-0c8ab644ddab/resourceGroups/mygroup/providers/Microsoft.Blockchain/blockchainMembers/contosemember1/transactionNodes/txnode2"), + // Location: to.Ptr("southeastasia"), + // Properties: &armblockchain.TransactionNodeProperties{ + // DNS: to.Ptr("txnode2-contosemember1.blockchain.azure.com"), + // ProvisioningState: to.Ptr(armblockchain.NodeProvisioningStateSucceeded), + // PublicKey: to.Ptr("DbRYTorBtY7rZfNfByUQpdC+hD3k/0lfA7+UnH4ovWM="), + // UserName: to.Ptr("txnode2"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_ListApiKeys.json +func ExampleTransactionNodesClient_ListAPIKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransactionNodesClient().ListAPIKeys(ctx, "contosemember1", "txnode2", "mygroup", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.APIKeyCollection = armblockchain.APIKeyCollection{ + // Keys: []*armblockchain.APIKey{ + // { + // KeyName: to.Ptr("key1"), + // Value: to.Ptr("-EnIUzu29xj60xPJmstyCURo"), + // }, + // { + // KeyName: to.Ptr("key2"), + // Value: to.Ptr("I8P-q4u_WDuCZUBYXnJ3yYX7"), + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_ListRegenerateApiKeys.json +func ExampleTransactionNodesClient_ListRegenerateAPIKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armblockchain.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransactionNodesClient().ListRegenerateAPIKeys(ctx, "contosemember1", "txnode2", "mygroup", &armblockchain.TransactionNodesClientListRegenerateAPIKeysOptions{APIKey: &armblockchain.APIKey{ + KeyName: to.Ptr("key1"), + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.APIKeyCollection = armblockchain.APIKeyCollection{ + // Keys: []*armblockchain.APIKey{ + // { + // KeyName: to.Ptr("key1"), + // Value: to.Ptr("-EnIUzu29xj60xPJmstyCURo"), + // }, + // { + // KeyName: to.Ptr("key2"), + // Value: to.Ptr("-EHio4yRJLxajDaxRNaoD7cZ"), + // }}, + // } +} diff --git a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmemberoperationresults_client_test.go b/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmemberoperationresults_client_test.go deleted file mode 100644 index 900d1d9461ef..000000000000 --- a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmemberoperationresults_client_test.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armblockchain_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMemberOperationResults_Get.json -func ExampleMemberOperationResultsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMemberOperationResultsClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "southeastasia", - "12f4b309-01e3-4fcf-bc0b-1cc034ca03f8", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmembers_client_test.go b/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmembers_client_test.go deleted file mode 100644 index 86b186a8f72c..000000000000 --- a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_blockchainmembers_client_test.go +++ /dev/null @@ -1,205 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armblockchain_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Get.json -func ExampleMembersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMembersClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contosemember1", - "mygroup", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Create.json -func ExampleMembersClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMembersClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "contosemember1", - "mygroup", - &armblockchain.MembersClientBeginCreateOptions{BlockchainMember: &armblockchain.Member{ - Location: to.Ptr("southeastasia"), - Properties: &armblockchain.MemberProperties{ - Consortium: to.Ptr("ContoseConsortium"), - ConsortiumManagementAccountPassword: to.Ptr(""), - Password: to.Ptr(""), - ValidatorNodesSKU: &armblockchain.MemberNodesSKU{ - Capacity: to.Ptr[int32](2), - }, - Protocol: to.Ptr(armblockchain.BlockchainProtocolQuorum), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Delete.json -func ExampleMembersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMembersClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "contosemember1", - "mygroup", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_Update.json -func ExampleMembersClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMembersClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "ContoseMember1", - "mygroup", - &armblockchain.MembersClientUpdateOptions{BlockchainMember: &armblockchain.MemberUpdate{ - Properties: &armblockchain.MemberPropertiesUpdate{ - Password: to.Ptr(""), - ConsortiumManagementAccountPassword: to.Ptr(""), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_List.json -func ExampleMembersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMembersClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("mygroup", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_ListAll.json -func ExampleMembersClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMembersClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAllPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/BlockchainMembers_ListConsortiumMembers.json -func ExampleMembersClient_NewListConsortiumMembersPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewMembersClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListConsortiumMembersPager("contosemember1", - "mygroup", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_locations_client_test.go b/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_locations_client_test.go deleted file mode 100644 index 3db3873a42b5..000000000000 --- a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_locations_client_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armblockchain_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Locations_CheckNameAvailability.json -func ExampleLocationsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewLocationsClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckNameAvailability(ctx, - "southeastasia", - &armblockchain.LocationsClientCheckNameAvailabilityOptions{NameAvailabilityRequest: &armblockchain.NameAvailabilityRequest{ - Name: to.Ptr("contosemember1"), - Type: to.Ptr("Microsoft.Blockchain/blockchainMembers"), - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Locations_ListConsortiums.json -func ExampleLocationsClient_ListConsortiums() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewLocationsClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListConsortiums(ctx, - "southeastasia", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_operations_client_test.go deleted file mode 100644 index 4263adf189e0..000000000000 --- a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armblockchain_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_skus_client_test.go b/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_skus_client_test.go deleted file mode 100644 index bb220dc1e2c1..000000000000 --- a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_skus_client_test.go +++ /dev/null @@ -1,37 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armblockchain_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/Skus_List.json -func ExampleSKUsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewSKUsClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_transactionnodes_client_test.go b/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_transactionnodes_client_test.go deleted file mode 100644 index 9e91264d2275..000000000000 --- a/sdk/resourcemanager/blockchain/armblockchain/ze_generated_example_transactionnodes_client_test.go +++ /dev/null @@ -1,153 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armblockchain_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blockchain/armblockchain" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Get.json -func ExampleTransactionNodesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewTransactionNodesClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contosemember1", - "txnode2", - "mygroup", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Create.json -func ExampleTransactionNodesClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewTransactionNodesClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "contosemember1", - "txnode2", - "mygroup", - &armblockchain.TransactionNodesClientBeginCreateOptions{TransactionNode: &armblockchain.TransactionNode{ - Location: to.Ptr("southeastasia"), - Properties: &armblockchain.TransactionNodeProperties{ - Password: to.Ptr(""), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Delete.json -func ExampleTransactionNodesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewTransactionNodesClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "contosemember1", - "txNode2", - "mygroup", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_Update.json -func ExampleTransactionNodesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewTransactionNodesClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "contosemember1", - "txnode2", - "mygroup", - &armblockchain.TransactionNodesClientUpdateOptions{TransactionNode: &armblockchain.TransactionNodeUpdate{ - Properties: &armblockchain.TransactionNodePropertiesUpdate{ - Password: to.Ptr(""), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/blockchain/resource-manager/Microsoft.Blockchain/preview/2018-06-01-preview/examples/TransactionNodes_List.json -func ExampleTransactionNodesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armblockchain.NewTransactionNodesClient("51766542-3ed7-4a72-a187-0c8ab644ddab", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contosemember1", - "mygroup", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_models_serde.go b/sdk/resourcemanager/blockchain/armblockchain/zz_generated_models_serde.go deleted file mode 100644 index 0fc13a77523a..000000000000 --- a/sdk/resourcemanager/blockchain/armblockchain/zz_generated_models_serde.go +++ /dev/null @@ -1,188 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armblockchain - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// UnmarshalJSON implements the json.Unmarshaller interface for type ConsortiumMember. -func (c *ConsortiumMember) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "dateModified": - err = unpopulateTimeRFC3339(val, "DateModified", &c.DateModified) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &c.DisplayName) - delete(rawMsg, key) - case "joinDate": - err = unpopulateTimeRFC3339(val, "JoinDate", &c.JoinDate) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - case "role": - err = unpopulate(val, "Role", &c.Role) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &c.Status) - delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &c.SubscriptionID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Member. -func (m Member) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", m.ID) - populate(objectMap, "location", m.Location) - populate(objectMap, "name", m.Name) - populate(objectMap, "properties", m.Properties) - populate(objectMap, "sku", m.SKU) - populate(objectMap, "tags", m.Tags) - populate(objectMap, "type", m.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type MemberProperties. -func (m MemberProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consortium", m.Consortium) - populate(objectMap, "consortiumManagementAccountAddress", m.ConsortiumManagementAccountAddress) - populate(objectMap, "consortiumManagementAccountPassword", m.ConsortiumManagementAccountPassword) - populate(objectMap, "consortiumMemberDisplayName", m.ConsortiumMemberDisplayName) - populate(objectMap, "consortiumRole", m.ConsortiumRole) - populate(objectMap, "dns", m.DNS) - populate(objectMap, "firewallRules", m.FirewallRules) - populate(objectMap, "password", m.Password) - populate(objectMap, "protocol", m.Protocol) - populate(objectMap, "provisioningState", m.ProvisioningState) - populate(objectMap, "publicKey", m.PublicKey) - populate(objectMap, "rootContractAddress", m.RootContractAddress) - populate(objectMap, "userName", m.UserName) - populate(objectMap, "validatorNodesSku", m.ValidatorNodesSKU) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type MemberPropertiesUpdate. -func (m MemberPropertiesUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consortiumManagementAccountPassword", m.ConsortiumManagementAccountPassword) - populate(objectMap, "firewallRules", m.FirewallRules) - populate(objectMap, "password", m.Password) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type MemberUpdate. -func (m MemberUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", m.Properties) - populate(objectMap, "tags", m.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResult. -func (o *OperationResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TransactionNodeProperties. -func (t TransactionNodeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "dns", t.DNS) - populate(objectMap, "firewallRules", t.FirewallRules) - populate(objectMap, "password", t.Password) - populate(objectMap, "provisioningState", t.ProvisioningState) - populate(objectMap, "publicKey", t.PublicKey) - populate(objectMap, "userName", t.UserName) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TransactionNodePropertiesUpdate. -func (t TransactionNodePropertiesUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "firewallRules", t.FirewallRules) - populate(objectMap, "password", t.Password) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TransactionNodeUpdate. -func (t TransactionNodeUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", t.Properties) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md b/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md index a932628c74c5..0e7020269ca6 100644 --- a/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md +++ b/sdk/resourcemanager/botservice/armbotservice/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2023-01-13) ### Breaking Changes diff --git a/sdk/resourcemanager/botservice/armbotservice/README.md b/sdk/resourcemanager/botservice/armbotservice/README.md index 21710885df2f..e356ed4850d8 100644 --- a/sdk/resourcemanager/botservice/armbotservice/README.md +++ b/sdk/resourcemanager/botservice/armbotservice/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Bot Service modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Bot Service module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armbotservice.NewBotsClient(, cred, nil) +clientFactory, err := armbotservice.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armbotservice.NewBotsClient(, cred, &options) +clientFactory, err := armbotservice.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewBotsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/botservice/armbotservice/autorest.md b/sdk/resourcemanager/botservice/armbotservice/autorest.md index 4ae6c5177ee5..a71eb972cb6f 100644 --- a/sdk/resourcemanager/botservice/armbotservice/autorest.md +++ b/sdk/resourcemanager/botservice/armbotservice/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/botservice/armbotservice/botconnection_client.go b/sdk/resourcemanager/botservice/armbotservice/botconnection_client.go index d83094a42aeb..60384eb9b8de 100644 --- a/sdk/resourcemanager/botservice/armbotservice/botconnection_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/botconnection_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // BotConnectionClient contains the methods for the BotConnection group. // Don't use this type directly, use NewBotConnectionClient() instead. type BotConnectionClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewBotConnectionClient creates a new instance of BotConnectionClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewBotConnectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BotConnectionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".BotConnectionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &BotConnectionClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Register a new Auth Connection for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// connectionName - The name of the Bot Service Connection Setting resource. -// parameters - The parameters to provide for creating the Connection Setting. -// options - BotConnectionClientCreateOptions contains the optional parameters for the BotConnectionClient.Create method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - connectionName - The name of the Bot Service Connection Setting resource. +// - parameters - The parameters to provide for creating the Connection Setting. +// - options - BotConnectionClientCreateOptions contains the optional parameters for the BotConnectionClient.Create method. func (client *BotConnectionClient) Create(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *BotConnectionClientCreateOptions) (BotConnectionClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, connectionName, parameters, options) if err != nil { return BotConnectionClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotConnectionClientCreateResponse{}, err } @@ -97,7 +87,7 @@ func (client *BotConnectionClient) createCreateRequest(ctx context.Context, reso return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,17 +109,18 @@ func (client *BotConnectionClient) createHandleResponse(resp *http.Response) (Bo // Delete - Deletes a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// connectionName - The name of the Bot Service Connection Setting resource. -// options - BotConnectionClientDeleteOptions contains the optional parameters for the BotConnectionClient.Delete method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - connectionName - The name of the Bot Service Connection Setting resource. +// - options - BotConnectionClientDeleteOptions contains the optional parameters for the BotConnectionClient.Delete method. func (client *BotConnectionClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientDeleteOptions) (BotConnectionClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, connectionName, options) if err != nil { return BotConnectionClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotConnectionClientDeleteResponse{}, err } @@ -158,7 +149,7 @@ func (client *BotConnectionClient) deleteCreateRequest(ctx context.Context, reso return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -171,17 +162,18 @@ func (client *BotConnectionClient) deleteCreateRequest(ctx context.Context, reso // Get - Get a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// connectionName - The name of the Bot Service Connection Setting resource. -// options - BotConnectionClientGetOptions contains the optional parameters for the BotConnectionClient.Get method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - connectionName - The name of the Bot Service Connection Setting resource. +// - options - BotConnectionClientGetOptions contains the optional parameters for the BotConnectionClient.Get method. func (client *BotConnectionClient) Get(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientGetOptions) (BotConnectionClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, connectionName, options) if err != nil { return BotConnectionClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotConnectionClientGetResponse{}, err } @@ -210,7 +202,7 @@ func (client *BotConnectionClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -231,11 +223,12 @@ func (client *BotConnectionClient) getHandleResponse(resp *http.Response) (BotCo } // NewListByBotServicePager - Returns all the Connection Settings registered to a particular BotService resource +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// options - BotConnectionClientListByBotServiceOptions contains the optional parameters for the BotConnectionClient.ListByBotService -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - options - BotConnectionClientListByBotServiceOptions contains the optional parameters for the BotConnectionClient.NewListByBotServicePager +// method. func (client *BotConnectionClient) NewListByBotServicePager(resourceGroupName string, resourceName string, options *BotConnectionClientListByBotServiceOptions) *runtime.Pager[BotConnectionClientListByBotServiceResponse] { return runtime.NewPager(runtime.PagingHandler[BotConnectionClientListByBotServiceResponse]{ More: func(page BotConnectionClientListByBotServiceResponse) bool { @@ -252,7 +245,7 @@ func (client *BotConnectionClient) NewListByBotServicePager(resourceGroupName st if err != nil { return BotConnectionClientListByBotServiceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotConnectionClientListByBotServiceResponse{}, err } @@ -279,7 +272,7 @@ func (client *BotConnectionClient) listByBotServiceCreateRequest(ctx context.Con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -301,15 +294,16 @@ func (client *BotConnectionClient) listByBotServiceHandleResponse(resp *http.Res // ListServiceProviders - Lists the available Service Providers for creating Connection Settings // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// options - BotConnectionClientListServiceProvidersOptions contains the optional parameters for the BotConnectionClient.ListServiceProviders -// method. +// - options - BotConnectionClientListServiceProvidersOptions contains the optional parameters for the BotConnectionClient.ListServiceProviders +// method. func (client *BotConnectionClient) ListServiceProviders(ctx context.Context, options *BotConnectionClientListServiceProvidersOptions) (BotConnectionClientListServiceProvidersResponse, error) { req, err := client.listServiceProvidersCreateRequest(ctx, options) if err != nil { return BotConnectionClientListServiceProvidersResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotConnectionClientListServiceProvidersResponse{}, err } @@ -326,7 +320,7 @@ func (client *BotConnectionClient) listServiceProvidersCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -348,18 +342,19 @@ func (client *BotConnectionClient) listServiceProvidersHandleResponse(resp *http // ListWithSecrets - Get a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// connectionName - The name of the Bot Service Connection Setting resource. -// options - BotConnectionClientListWithSecretsOptions contains the optional parameters for the BotConnectionClient.ListWithSecrets -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - connectionName - The name of the Bot Service Connection Setting resource. +// - options - BotConnectionClientListWithSecretsOptions contains the optional parameters for the BotConnectionClient.ListWithSecrets +// method. func (client *BotConnectionClient) ListWithSecrets(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, options *BotConnectionClientListWithSecretsOptions) (BotConnectionClientListWithSecretsResponse, error) { req, err := client.listWithSecretsCreateRequest(ctx, resourceGroupName, resourceName, connectionName, options) if err != nil { return BotConnectionClientListWithSecretsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotConnectionClientListWithSecretsResponse{}, err } @@ -388,7 +383,7 @@ func (client *BotConnectionClient) listWithSecretsCreateRequest(ctx context.Cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -410,18 +405,19 @@ func (client *BotConnectionClient) listWithSecretsHandleResponse(resp *http.Resp // Update - Updates a Connection Setting registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// connectionName - The name of the Bot Service Connection Setting resource. -// parameters - The parameters to provide for updating the Connection Setting. -// options - BotConnectionClientUpdateOptions contains the optional parameters for the BotConnectionClient.Update method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - connectionName - The name of the Bot Service Connection Setting resource. +// - parameters - The parameters to provide for updating the Connection Setting. +// - options - BotConnectionClientUpdateOptions contains the optional parameters for the BotConnectionClient.Update method. func (client *BotConnectionClient) Update(ctx context.Context, resourceGroupName string, resourceName string, connectionName string, parameters ConnectionSetting, options *BotConnectionClientUpdateOptions) (BotConnectionClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, connectionName, parameters, options) if err != nil { return BotConnectionClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotConnectionClientUpdateResponse{}, err } @@ -450,7 +446,7 @@ func (client *BotConnectionClient) updateCreateRequest(ctx context.Context, reso return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/botconnection_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/botconnection_client_example_test.go index b3a3f68eb50f..9d00e11ef482 100644 --- a/sdk/resourcemanager/botservice/armbotservice/botconnection_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/botconnection_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -17,56 +18,100 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListServiceProviders.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListServiceProviders.json func ExampleBotConnectionClient_ListServiceProviders() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotConnectionClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListServiceProviders(ctx, nil) + res, err := clientFactory.NewBotConnectionClient().ListServiceProviders(ctx, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServiceProviderResponseList = armbotservice.ServiceProviderResponseList{ + // Value: []*armbotservice.ServiceProvider{ + // { + // Properties: &armbotservice.ServiceProviderProperties{ + // DevPortalURL: to.Ptr("sampleDevPortalUrl"), + // DisplayName: to.Ptr("sample service provider display name"), + // IconURL: to.Ptr("sampleIconUrl"), + // ID: to.Ptr("sampleServiceProviderId"), + // Parameters: []*armbotservice.ServiceProviderParameter{ + // { + // Name: to.Ptr("sampleParameterName"), + // Type: to.Ptr("sampleParameterType"), + // Description: to.Ptr("sampleDescription"), + // Default: to.Ptr("sampleDefaultValue"), + // DisplayName: to.Ptr("sampleDisplayName"), + // HelpURL: to.Ptr("sampleHelpUrl"), + // }}, + // ServiceProviderName: to.Ptr("sampleServiceProvider"), + // }, + // }}, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json func ExampleBotConnectionClient_ListWithSecrets() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotConnectionClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListWithSecrets(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) + res, err := clientFactory.NewBotConnectionClient().ListWithSecrets(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConnectionSetting = armbotservice.ConnectionSetting{ + // Name: to.Ptr("sampleConnection"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // ClientID: to.Ptr("sampleclientid"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }}, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutConnection.json func ExampleBotConnectionClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotConnectionClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", armbotservice.ConnectionSetting{ + res, err := clientFactory.NewBotConnectionClient().Create(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", armbotservice.ConnectionSetting{ Etag: to.Ptr("etag1"), Location: to.Ptr("West US"), Properties: &armbotservice.ConnectionSettingProperties{ @@ -88,22 +133,44 @@ func ExampleBotConnectionClient_Create() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConnectionSetting = armbotservice.ConnectionSetting{ + // Name: to.Ptr("sampleConnection"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // ClientID: to.Ptr("sampleclientid"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }}, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateConnection.json func ExampleBotConnectionClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotConnectionClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", armbotservice.ConnectionSetting{ + res, err := clientFactory.NewBotConnectionClient().Update(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", armbotservice.ConnectionSetting{ Etag: to.Ptr("etag1"), Location: to.Ptr("global"), Properties: &armbotservice.ConnectionSettingProperties{ @@ -126,47 +193,90 @@ func ExampleBotConnectionClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConnectionSetting = armbotservice.ConnectionSetting{ + // Name: to.Ptr("sampleConnection"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/connections/sampleConnection"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // ClientID: to.Ptr("sampleclientid"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }}, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderDisplayName: to.Ptr("serviceProviderDisplayName"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteConnection.json func ExampleBotConnectionClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotConnectionClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) + _, err = clientFactory.NewBotConnectionClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "sampleConnection", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListConnectionsByBotService.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListConnectionsByBotService.json func ExampleBotConnectionClient_NewListByBotServicePager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotConnectionClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByBotServicePager("OneResourceGroupName", "samplebotname", nil) + pager := clientFactory.NewBotConnectionClient().NewListByBotServicePager("OneResourceGroupName", "samplebotname", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ConnectionSettingResponseList = armbotservice.ConnectionSettingResponseList{ + // Value: []*armbotservice.ConnectionSetting{ + // { + // Name: to.Ptr("sampleConnection"), + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Properties: &armbotservice.ConnectionSettingProperties{ + // ClientID: to.Ptr("sampleclientid"), + // Parameters: []*armbotservice.ConnectionSettingParameter{ + // { + // Key: to.Ptr("key1"), + // Value: to.Ptr("value1"), + // }, + // { + // Key: to.Ptr("key2"), + // Value: to.Ptr("value2"), + // }}, + // Scopes: to.Ptr("samplescope"), + // ServiceProviderID: to.Ptr("serviceproviderid"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/botservice/armbotservice/bots_client.go b/sdk/resourcemanager/botservice/armbotservice/bots_client.go index d3978fac962f..b1187a91a19d 100644 --- a/sdk/resourcemanager/botservice/armbotservice/bots_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/bots_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // BotsClient contains the methods for the Bots group. // Don't use this type directly, use NewBotsClient() instead. type BotsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewBotsClient creates a new instance of BotsClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewBotsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BotsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".BotsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &BotsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Creates a Bot Service. Bot Service is a resource group wide resource type. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// parameters - The parameters to provide for the created bot. -// options - BotsClientCreateOptions contains the optional parameters for the BotsClient.Create method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - parameters - The parameters to provide for the created bot. +// - options - BotsClientCreateOptions contains the optional parameters for the BotsClient.Create method. func (client *BotsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, parameters Bot, options *BotsClientCreateOptions) (BotsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return BotsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotsClientCreateResponse{}, err } @@ -92,7 +82,7 @@ func (client *BotsClient) createCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,16 +104,17 @@ func (client *BotsClient) createHandleResponse(resp *http.Response) (BotsClientC // Delete - Deletes a Bot Service from the resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// options - BotsClientDeleteOptions contains the optional parameters for the BotsClient.Delete method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - options - BotsClientDeleteOptions contains the optional parameters for the BotsClient.Delete method. func (client *BotsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientDeleteOptions) (BotsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return BotsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotsClientDeleteResponse{}, err } @@ -148,7 +139,7 @@ func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -161,16 +152,17 @@ func (client *BotsClient) deleteCreateRequest(ctx context.Context, resourceGroup // Get - Returns a BotService specified by the parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// options - BotsClientGetOptions contains the optional parameters for the BotsClient.Get method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - options - BotsClientGetOptions contains the optional parameters for the BotsClient.Get method. func (client *BotsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *BotsClientGetOptions) (BotsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return BotsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotsClientGetResponse{}, err } @@ -195,7 +187,7 @@ func (client *BotsClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -217,16 +209,17 @@ func (client *BotsClient) getHandleResponse(resp *http.Response) (BotsClientGetR // GetCheckNameAvailability - Check whether a bot name is available. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// parameters - The request body parameters to provide for the check name availability request -// options - BotsClientGetCheckNameAvailabilityOptions contains the optional parameters for the BotsClient.GetCheckNameAvailability -// method. +// - parameters - The request body parameters to provide for the check name availability request +// - options - BotsClientGetCheckNameAvailabilityOptions contains the optional parameters for the BotsClient.GetCheckNameAvailability +// method. func (client *BotsClient) GetCheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequestBody, options *BotsClientGetCheckNameAvailabilityOptions) (BotsClientGetCheckNameAvailabilityResponse, error) { req, err := client.getCheckNameAvailabilityCreateRequest(ctx, parameters, options) if err != nil { return BotsClientGetCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotsClientGetCheckNameAvailabilityResponse{}, err } @@ -239,7 +232,7 @@ func (client *BotsClient) GetCheckNameAvailability(ctx context.Context, paramete // getCheckNameAvailabilityCreateRequest creates the GetCheckNameAvailability request. func (client *BotsClient) getCheckNameAvailabilityCreateRequest(ctx context.Context, parameters CheckNameAvailabilityRequestBody, options *BotsClientGetCheckNameAvailabilityOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BotService/checkNameAvailability" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -260,8 +253,9 @@ func (client *BotsClient) getCheckNameAvailabilityHandleResponse(resp *http.Resp } // NewListPager - Returns all the resources of a particular type belonging to a subscription. +// // Generated from API version 2022-09-15 -// options - BotsClientListOptions contains the optional parameters for the BotsClient.List method. +// - options - BotsClientListOptions contains the optional parameters for the BotsClient.NewListPager method. func (client *BotsClient) NewListPager(options *BotsClientListOptions) *runtime.Pager[BotsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[BotsClientListResponse]{ More: func(page BotsClientListResponse) bool { @@ -278,7 +272,7 @@ func (client *BotsClient) NewListPager(options *BotsClientListOptions) *runtime. if err != nil { return BotsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotsClientListResponse{}, err } @@ -297,7 +291,7 @@ func (client *BotsClient) listCreateRequest(ctx context.Context, options *BotsCl return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -318,10 +312,11 @@ func (client *BotsClient) listHandleResponse(resp *http.Response) (BotsClientLis } // NewListByResourceGroupPager - Returns all the resources of a particular type belonging to a resource group +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// options - BotsClientListByResourceGroupOptions contains the optional parameters for the BotsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - options - BotsClientListByResourceGroupOptions contains the optional parameters for the BotsClient.NewListByResourceGroupPager +// method. func (client *BotsClient) NewListByResourceGroupPager(resourceGroupName string, options *BotsClientListByResourceGroupOptions) *runtime.Pager[BotsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[BotsClientListByResourceGroupResponse]{ More: func(page BotsClientListByResourceGroupResponse) bool { @@ -338,7 +333,7 @@ func (client *BotsClient) NewListByResourceGroupPager(resourceGroupName string, if err != nil { return BotsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotsClientListByResourceGroupResponse{}, err } @@ -361,7 +356,7 @@ func (client *BotsClient) listByResourceGroupCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -383,17 +378,18 @@ func (client *BotsClient) listByResourceGroupHandleResponse(resp *http.Response) // Update - Updates a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// parameters - The parameters to provide for the created bot. -// options - BotsClientUpdateOptions contains the optional parameters for the BotsClient.Update method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - parameters - The parameters to provide for the created bot. +// - options - BotsClientUpdateOptions contains the optional parameters for the BotsClient.Update method. func (client *BotsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters Bot, options *BotsClientUpdateOptions) (BotsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return BotsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BotsClientUpdateResponse{}, err } @@ -418,7 +414,7 @@ func (client *BotsClient) updateCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go index b147fcd995e8..24b92a0207bc 100644 --- a/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/bots_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CreateBot.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CreateBot.json func ExampleBotsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.Bot{ + res, err := clientFactory.NewBotsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.Bot{ Etag: to.Ptr("etag1"), Kind: to.Ptr(armbotservice.KindSdk), Location: to.Ptr("West US"), @@ -65,22 +66,61 @@ func ExampleBotsClient_Create() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Bot = armbotservice.Bot{ + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme")}, + // DeveloperAppInsightKey: to.Ptr("appinsightskey"), + // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), + // DisableLocalAuth: to.Ptr(true), + // DisplayName: to.Ptr("The Name of the bot"), + // EnabledChannels: []*string{ + // to.Ptr("facebook")}, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2")}, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateBot.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateBot.json func ExampleBotsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.Bot{ + res, err := clientFactory.NewBotsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.Bot{ Etag: to.Ptr("etag1"), Kind: to.Ptr(armbotservice.KindSdk), Location: to.Ptr("West US"), @@ -117,112 +157,294 @@ func ExampleBotsClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Bot = armbotservice.Bot{ + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme")}, + // DeveloperAppInsightKey: to.Ptr("appinsightskey"), + // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), + // DisableLocalAuth: to.Ptr(true), + // DisplayName: to.Ptr("The Name of the bot"), + // EnabledChannels: []*string{ + // to.Ptr("facebook")}, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2")}, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteBot.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteBot.json func ExampleBotsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "OneResourceGroupName", "samplebotname", nil) + _, err = clientFactory.NewBotsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json func ExampleBotsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "OneResourceGroupName", "samplebotname", nil) + res, err := clientFactory.NewBotsClient().Get(ctx, "OneResourceGroupName", "samplebotname", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Bot = armbotservice.Bot{ + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme")}, + // DeveloperAppInsightKey: to.Ptr("appinsightskey"), + // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), + // DisableLocalAuth: to.Ptr(true), + // DisplayName: to.Ptr("The Name of the bot"), + // EnabledChannels: []*string{ + // to.Ptr("facebook")}, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2")}, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PrivateEndpointConnections: []*armbotservice.PrivateEndpointConnection{ + // { + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname/privateEndpointConnections/privatelink"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.Network/privateEndpoints/privatelink"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsByResourceGroup.json func ExampleBotsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("OneResourceGroupName", nil) + pager := clientFactory.NewBotsClient().NewListByResourceGroupPager("OneResourceGroupName", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.BotResponseList = armbotservice.BotResponseList{ + // Value: []*armbotservice.Bot{ + // { + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme")}, + // DeveloperAppInsightKey: to.Ptr("appinsightskey"), + // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), + // DisableLocalAuth: to.Ptr(true), + // DisplayName: to.Ptr("The Name of the bot"), + // EnabledChannels: []*string{ + // to.Ptr("facebook")}, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2")}, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsBySubscription.json func ExampleBotsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewBotsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.BotResponseList = armbotservice.BotResponseList{ + // Value: []*armbotservice.Bot{ + // { + // Name: to.Ptr("samplebotname"), + // Type: to.Ptr("Microsoft.BotService/botServices"), + // Etag: to.Ptr("etag1"), + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Kind: to.Ptr(armbotservice.KindSdk), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armbotservice.BotProperties{ + // Description: to.Ptr("The description of the bot"), + // CmekKeyVaultURL: to.Ptr("https://myCmekKey"), + // ConfiguredChannels: []*string{ + // to.Ptr("facebook"), + // to.Ptr("groupme")}, + // DeveloperAppInsightKey: to.Ptr("appinsightskey"), + // DeveloperAppInsightsApplicationID: to.Ptr("appinsightsappid"), + // DisableLocalAuth: to.Ptr(true), + // DisplayName: to.Ptr("The Name of the bot"), + // EnabledChannels: []*string{ + // to.Ptr("facebook")}, + // Endpoint: to.Ptr("http://mybot.coffee"), + // EndpointVersion: to.Ptr("version"), + // IconURL: to.Ptr("http://myicon"), + // IsCmekEnabled: to.Ptr(true), + // LuisAppIDs: []*string{ + // to.Ptr("luisappid1"), + // to.Ptr("luisappid2")}, + // MsaAppID: to.Ptr("msaappid"), + // MsaAppMSIResourceID: to.Ptr("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + // MsaAppTenantID: to.Ptr("msaapptenantid"), + // MsaAppType: to.Ptr(armbotservice.MsaAppTypeUserAssignedMSI), + // PublicNetworkAccess: to.Ptr(armbotservice.PublicNetworkAccessEnabled), + // SchemaTransformationVersion: to.Ptr("1.0"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CheckNameAvailability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CheckNameAvailability.json func ExampleBotsClient_GetCheckNameAvailability() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewBotsClient("", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetCheckNameAvailability(ctx, armbotservice.CheckNameAvailabilityRequestBody{ + res, err := clientFactory.NewBotsClient().GetCheckNameAvailability(ctx, armbotservice.CheckNameAvailabilityRequestBody{ Name: to.Ptr("testbotname"), Type: to.Ptr("string"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckNameAvailabilityResponseBody = armbotservice.CheckNameAvailabilityResponseBody{ + // Message: to.Ptr("custom message from server"), + // Valid: to.Ptr(true), + // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/channels_client.go b/sdk/resourcemanager/botservice/armbotservice/channels_client.go index c458f01839fb..b21a52d77512 100644 --- a/sdk/resourcemanager/botservice/armbotservice/channels_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/channels_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,49 +24,41 @@ import ( // ChannelsClient contains the methods for the Channels group. // Don't use this type directly, use NewChannelsClient() instead. type ChannelsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewChannelsClient creates a new instance of ChannelsClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewChannelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ChannelsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ChannelsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ChannelsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Creates a Channel registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// channelName - The name of the Channel resource. -// parameters - The parameters to provide for the created bot. -// options - ChannelsClientCreateOptions contains the optional parameters for the ChannelsClient.Create method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - channelName - The name of the Channel resource. +// - parameters - The parameters to provide for the created bot. +// - options - ChannelsClientCreateOptions contains the optional parameters for the ChannelsClient.Create method. func (client *ChannelsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, parameters BotChannel, options *ChannelsClientCreateOptions) (ChannelsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, channelName, parameters, options) if err != nil { return ChannelsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientCreateResponse{}, err } @@ -97,7 +87,7 @@ func (client *ChannelsClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,17 +109,18 @@ func (client *ChannelsClient) createHandleResponse(resp *http.Response) (Channel // Delete - Deletes a Channel registration from a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// channelName - The name of the Bot resource. -// options - ChannelsClientDeleteOptions contains the optional parameters for the ChannelsClient.Delete method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - channelName - The name of the Bot resource. +// - options - ChannelsClientDeleteOptions contains the optional parameters for the ChannelsClient.Delete method. func (client *ChannelsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *ChannelsClientDeleteOptions) (ChannelsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, channelName, options) if err != nil { return ChannelsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientDeleteResponse{}, err } @@ -158,7 +149,7 @@ func (client *ChannelsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -171,17 +162,18 @@ func (client *ChannelsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Returns a BotService Channel registration specified by the parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// channelName - The name of the Bot resource. -// options - ChannelsClientGetOptions contains the optional parameters for the ChannelsClient.Get method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - channelName - The name of the Bot resource. +// - options - ChannelsClientGetOptions contains the optional parameters for the ChannelsClient.Get method. func (client *ChannelsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, channelName string, options *ChannelsClientGetOptions) (ChannelsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, channelName, options) if err != nil { return ChannelsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientGetResponse{}, err } @@ -210,7 +202,7 @@ func (client *ChannelsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -231,11 +223,12 @@ func (client *ChannelsClient) getHandleResponse(resp *http.Response) (ChannelsCl } // NewListByResourceGroupPager - Returns all the Channel registrations of a particular BotService resource +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// options - ChannelsClientListByResourceGroupOptions contains the optional parameters for the ChannelsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - options - ChannelsClientListByResourceGroupOptions contains the optional parameters for the ChannelsClient.NewListByResourceGroupPager +// method. func (client *ChannelsClient) NewListByResourceGroupPager(resourceGroupName string, resourceName string, options *ChannelsClientListByResourceGroupOptions) *runtime.Pager[ChannelsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ChannelsClientListByResourceGroupResponse]{ More: func(page ChannelsClientListByResourceGroupResponse) bool { @@ -252,7 +245,7 @@ func (client *ChannelsClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return ChannelsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientListByResourceGroupResponse{}, err } @@ -279,7 +272,7 @@ func (client *ChannelsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -301,17 +294,18 @@ func (client *ChannelsClient) listByResourceGroupHandleResponse(resp *http.Respo // ListWithKeys - Lists a Channel registration for a Bot Service including secrets // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// channelName - The name of the Channel resource. -// options - ChannelsClientListWithKeysOptions contains the optional parameters for the ChannelsClient.ListWithKeys method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - channelName - The name of the Channel resource. +// - options - ChannelsClientListWithKeysOptions contains the optional parameters for the ChannelsClient.ListWithKeys method. func (client *ChannelsClient) ListWithKeys(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, options *ChannelsClientListWithKeysOptions) (ChannelsClientListWithKeysResponse, error) { req, err := client.listWithKeysCreateRequest(ctx, resourceGroupName, resourceName, channelName, options) if err != nil { return ChannelsClientListWithKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientListWithKeysResponse{}, err } @@ -340,7 +334,7 @@ func (client *ChannelsClient) listWithKeysCreateRequest(ctx context.Context, res return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -362,18 +356,19 @@ func (client *ChannelsClient) listWithKeysHandleResponse(resp *http.Response) (C // Update - Updates a Channel registration for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// channelName - The name of the Channel resource. -// parameters - The parameters to provide for the created bot. -// options - ChannelsClientUpdateOptions contains the optional parameters for the ChannelsClient.Update method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - channelName - The name of the Channel resource. +// - parameters - The parameters to provide for the created bot. +// - options - ChannelsClientUpdateOptions contains the optional parameters for the ChannelsClient.Update method. func (client *ChannelsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, channelName ChannelName, parameters BotChannel, options *ChannelsClientUpdateOptions) (ChannelsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, channelName, parameters, options) if err != nil { return ChannelsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientUpdateResponse{}, err } @@ -402,7 +397,7 @@ func (client *ChannelsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/channels_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/channels_client_example_test.go index a95c6fb63ae4..aafa11d4684c 100644 --- a/sdk/resourcemanager/botservice/armbotservice/channels_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/channels_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutAlexaChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutAlexaChannel.json func ExampleChannelsClient_Create_createAlexaChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameAlexaChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameAlexaChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.AlexaChannel{ ChannelName: to.Ptr("AlexaChannel"), @@ -41,22 +42,36 @@ func ExampleChannelsClient_Create_createAlexaChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.AlexaChannel{ + // ChannelName: to.Ptr("AlexaChannel"), + // Properties: &armbotservice.AlexaChannelProperties{ + // AlexaSkillID: to.Ptr("alexa skill id"), + // IsEnabled: to.Ptr(true), + // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), + // URLFragment: to.Ptr("XUrlFragmentX"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutChannel.json func ExampleChannelsClient_Create_createChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.EmailChannel{ ChannelName: to.Ptr("EmailChannel"), @@ -70,22 +85,35 @@ func ExampleChannelsClient_Create_createChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutDirectLineSpeechChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutDirectLineSpeechChannel.json func ExampleChannelsClient_Create_createDirectLineSpeechChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameDirectLineSpeechChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameDirectLineSpeechChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.DirectLineSpeechChannel{ ChannelName: to.Ptr("DirectLineSpeechChannel"), @@ -99,22 +127,34 @@ func ExampleChannelsClient_Create_createDirectLineSpeechChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineSpeechChannel{ + // ChannelName: to.Ptr("DirectLineSpeechChannel"), + // Properties: &armbotservice.DirectLineSpeechChannelProperties{ + // CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), + // IsEnabled: to.Ptr(true), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutEmailChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutEmailChannel.json func ExampleChannelsClient_Create_createEmailChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.EmailChannel{ ChannelName: to.Ptr("EmailChannel"), @@ -129,22 +169,35 @@ func ExampleChannelsClient_Create_createEmailChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // AuthMethod: to.Ptr(armbotservice.EmailChannelAuthMethodGraph), + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutLineChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutLineChannel.json func ExampleChannelsClient_Create_createLineChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameLineChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Create(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameLineChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.LineChannel{ ChannelName: to.Ptr("LineChannel"), @@ -160,22 +213,38 @@ func ExampleChannelsClient_Create_createLineChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.LineChannel{ + // ChannelName: to.Ptr("LineChannel"), + // Properties: &armbotservice.LineChannelProperties{ + // CallbackURL: to.Ptr("http://callbackUrl"), + // IsValidated: to.Ptr(true), + // LineRegistrations: []*armbotservice.LineRegistration{ + // { + // GeneratedID: to.Ptr("id"), + // }}, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateAlexaChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateAlexaChannel.json func ExampleChannelsClient_Update_updateAlexaChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameAlexaChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameAlexaChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.AlexaChannel{ ChannelName: to.Ptr("AlexaChannel"), @@ -188,22 +257,36 @@ func ExampleChannelsClient_Update_updateAlexaChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.AlexaChannel{ + // ChannelName: to.Ptr("AlexaChannel"), + // Properties: &armbotservice.AlexaChannelProperties{ + // AlexaSkillID: to.Ptr("XAlexaSkillIdX"), + // IsEnabled: to.Ptr(true), + // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), + // URLFragment: to.Ptr("XUrlFragmentX"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateChannel.json func ExampleChannelsClient_Update_updateChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.EmailChannel{ ChannelName: to.Ptr("EmailChannel"), @@ -217,22 +300,35 @@ func ExampleChannelsClient_Update_updateChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateDirectLineSpeechChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateDirectLineSpeechChannel.json func ExampleChannelsClient_Update_updateDirectLineSpeechChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameDirectLineSpeechChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameDirectLineSpeechChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.DirectLineSpeechChannel{ ChannelName: to.Ptr("DirectLineSpeechChannel"), @@ -246,22 +342,34 @@ func ExampleChannelsClient_Update_updateDirectLineSpeechChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineSpeechChannel{ + // ChannelName: to.Ptr("DirectLineSpeechChannel"), + // Properties: &armbotservice.DirectLineSpeechChannelProperties{ + // CognitiveServiceRegion: to.Ptr("XcognitiveServiceRegionX"), + // IsEnabled: to.Ptr(true), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateLineChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateLineChannel.json func ExampleChannelsClient_Update_updateLineChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameLineChannel, armbotservice.BotChannel{ + res, err := clientFactory.NewChannelsClient().Update(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameLineChannel, armbotservice.BotChannel{ Location: to.Ptr("global"), Properties: &armbotservice.LineChannel{ ChannelName: to.Ptr("LineChannel"), @@ -277,159 +385,325 @@ func ExampleChannelsClient_Update_updateLineChannel() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.LineChannel{ + // ChannelName: to.Ptr("LineChannel"), + // Properties: &armbotservice.LineChannelProperties{ + // CallbackURL: to.Ptr("http://callbackUrl"), + // IsValidated: to.Ptr(true), + // LineRegistrations: []*armbotservice.LineRegistration{ + // { + // GeneratedID: to.Ptr("id"), + // }}, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteChannel.json func ExampleChannelsClient_Delete_deleteChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + _, err = clientFactory.NewChannelsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteDirectLineSpeechChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteDirectLineSpeechChannel.json func ExampleChannelsClient_Delete_deleteDirectLineSpeechChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) + _, err = clientFactory.NewChannelsClient().Delete(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json func ExampleChannelsClient_Get_getAlexaChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "OneResourceGroupName", "samplebotname", "AlexaChannel", nil) + res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "AlexaChannel", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.AlexaChannel{ + // ChannelName: to.Ptr("AlexaChannel"), + // Properties: &armbotservice.AlexaChannelProperties{ + // AlexaSkillID: to.Ptr("alexa skill id"), + // IsEnabled: to.Ptr(true), + // ServiceEndpointURI: to.Ptr("https://domain/XUrlFragmentX/botId"), + // URLFragment: to.Ptr("XUrlFragmentX"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json func ExampleChannelsClient_Get_getChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) + res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "EmailChannel", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json func ExampleChannelsClient_Get_getDirectLineSpeechChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) + res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "DirectLineSpeechChannel", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineSpeechChannel{ + // ChannelName: to.Ptr("DirectLineSpeechChannel"), + // Properties: &armbotservice.DirectLineSpeechChannelProperties{ + // CognitiveServiceRegion: to.Ptr("Cognitive service region"), + // CustomSpeechModelID: to.Ptr("Custom speech model ID"), + // CustomVoiceDeploymentID: to.Ptr("Custom voice deployment ID"), + // IsDefaultBotForCogSvcAccount: to.Ptr(true), + // IsEnabled: to.Ptr(true), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json func ExampleChannelsClient_Get_getLineChannel() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "OneResourceGroupName", "samplebotname", "LineChannel", nil) + res, err := clientFactory.NewChannelsClient().Get(ctx, "OneResourceGroupName", "samplebotname", "LineChannel", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.LineChannel{ + // ChannelName: to.Ptr("LineChannel"), + // Properties: &armbotservice.LineChannelProperties{ + // CallbackURL: to.Ptr("http://callbackUrl"), + // IsValidated: to.Ptr(true), + // LineRegistrations: []*armbotservice.LineRegistration{ + // { + // GeneratedID: to.Ptr("id"), + // }}, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannel.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannel.json func ExampleChannelsClient_ListWithKeys() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListWithKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, nil) + res, err := clientFactory.NewChannelsClient().ListWithKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.ChannelNameEmailChannel, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListChannelWithKeysResponse = armbotservice.ListChannelWithKeysResponse{ + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // Resource: &armbotservice.DirectLineChannel{ + // ChannelName: to.Ptr("DirectLineChannel"), + // Etag: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Location: to.Ptr("aaaaaa"), + // Properties: &armbotservice.DirectLineChannelProperties{ + // Sites: []*armbotservice.DirectLineSite{ + // { + // IsBlockUserUploadEnabled: to.Ptr(false), + // IsEnabled: to.Ptr(true), + // IsSecureSiteEnabled: to.Ptr(false), + // IsV1Enabled: to.Ptr(true), + // IsV3Enabled: to.Ptr(true), + // Key: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Key2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // SiteID: to.Ptr("aaaaaaaaaaa"), + // SiteName: to.Ptr("aaaaaaaaaaaa"), + // TrustedOrigins: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")}, + // }}, + // }, + // }, + // Setting: &armbotservice.ChannelSettings{ + // BotIconURL: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // BotID: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // ChannelDisplayName: to.Ptr("aaaaaaaaaaa"), + // ChannelID: to.Ptr("aaaaaaaaaa"), + // DisableLocalAuth: to.Ptr(false), + // ExtensionKey1: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // ExtensionKey2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // IsEnabled: to.Ptr(true), + // Sites: []*armbotservice.Site{ + // { + // ETag: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // IsBlockUserUploadEnabled: to.Ptr(false), + // IsEnabled: to.Ptr(true), + // IsSecureSiteEnabled: to.Ptr(false), + // IsTokenEnabled: to.Ptr(false), + // IsV1Enabled: to.Ptr(true), + // IsV3Enabled: to.Ptr(true), + // IsWebchatPreviewEnabled: to.Ptr(false), + // Key: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Key2: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // SiteID: to.Ptr("aaaaaaaaaaa"), + // SiteName: to.Ptr("aaaaaaaaaaaa"), + // TrustedOrigins: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")}, + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannelsByBotService.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannelsByBotService.json func ExampleChannelsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewChannelsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("OneResourceGroupName", "samplebotname", nil) + pager := clientFactory.NewChannelsClient().NewListByResourceGroupPager("OneResourceGroupName", "samplebotname", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ChannelResponseList = armbotservice.ChannelResponseList{ + // Value: []*armbotservice.BotChannel{ + // { + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.EmailChannel{ + // ChannelName: to.Ptr("EmailChannel"), + // Properties: &armbotservice.EmailChannelProperties{ + // EmailAddress: to.Ptr("a@b.com"), + // IsEnabled: to.Ptr(true), + // Password: to.Ptr("pwd"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/subscription-id/providers/Microsoft.BotService/botServices"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.FacebookChannel{ + // ChannelName: to.Ptr("FacebookChannel"), + // Properties: &armbotservice.FacebookChannelProperties{ + // AppID: to.Ptr("id"), + // CallbackURL: to.Ptr("appid"), + // IsEnabled: to.Ptr(true), + // Pages: []*armbotservice.FacebookPage{ + // { + // ID: to.Ptr("id"), + // }}, + // }, + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/botservice/armbotservice/client_factory.go b/sdk/resourcemanager/botservice/armbotservice/client_factory.go new file mode 100644 index 000000000000..a2b2957a5a96 --- /dev/null +++ b/sdk/resourcemanager/botservice/armbotservice/client_factory.go @@ -0,0 +1,94 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armbotservice + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewBotsClient() *BotsClient { + subClient, _ := NewBotsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewChannelsClient() *ChannelsClient { + subClient, _ := NewChannelsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDirectLineClient() *DirectLineClient { + subClient, _ := NewDirectLineClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEmailClient() *EmailClient { + subClient, _ := NewEmailClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewBotConnectionClient() *BotConnectionClient { + subClient, _ := NewBotConnectionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewQnAMakerEndpointKeysClient() *QnAMakerEndpointKeysClient { + subClient, _ := NewQnAMakerEndpointKeysClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHostSettingsClient() *HostSettingsClient { + subClient, _ := NewHostSettingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationResultsClient() *OperationResultsClient { + subClient, _ := NewOperationResultsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { + subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { + subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/botservice/armbotservice/constants.go b/sdk/resourcemanager/botservice/armbotservice/constants.go index 8e4cb3da8d53..54b40004ba12 100644 --- a/sdk/resourcemanager/botservice/armbotservice/constants.go +++ b/sdk/resourcemanager/botservice/armbotservice/constants.go @@ -11,7 +11,7 @@ package armbotservice const ( moduleName = "armbotservice" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) type ChannelName string diff --git a/sdk/resourcemanager/botservice/armbotservice/directline_client.go b/sdk/resourcemanager/botservice/armbotservice/directline_client.go index 602b2e4e8d8d..d8833ef8b1b2 100644 --- a/sdk/resourcemanager/botservice/armbotservice/directline_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/directline_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,50 +24,42 @@ import ( // DirectLineClient contains the methods for the DirectLine group. // Don't use this type directly, use NewDirectLineClient() instead. type DirectLineClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDirectLineClient creates a new instance of DirectLineClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDirectLineClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DirectLineClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DirectLineClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DirectLineClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // RegenerateKeys - Regenerates secret keys and returns them for the DirectLine Channel of a particular BotService resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// channelName - The name of the Channel resource for which keys are to be regenerated. -// parameters - The parameters to provide for the created bot. -// options - DirectLineClientRegenerateKeysOptions contains the optional parameters for the DirectLineClient.RegenerateKeys -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - channelName - The name of the Channel resource for which keys are to be regenerated. +// - parameters - The parameters to provide for the created bot. +// - options - DirectLineClientRegenerateKeysOptions contains the optional parameters for the DirectLineClient.RegenerateKeys +// method. func (client *DirectLineClient) RegenerateKeys(ctx context.Context, resourceGroupName string, resourceName string, channelName RegenerateKeysChannelName, parameters SiteInfo, options *DirectLineClientRegenerateKeysOptions) (DirectLineClientRegenerateKeysResponse, error) { req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, resourceName, channelName, parameters, options) if err != nil { return DirectLineClientRegenerateKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectLineClientRegenerateKeysResponse{}, err } @@ -98,7 +88,7 @@ func (client *DirectLineClient) regenerateKeysCreateRequest(ctx context.Context, return nil, errors.New("parameter channelName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(string(channelName))) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/directline_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/directline_client_example_test.go index eaeb399bacac..c7c230411c8d 100644 --- a/sdk/resourcemanager/botservice/armbotservice/directline_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/directline_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -17,46 +18,83 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DirectlineRegenerateKeys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DirectlineRegenerateKeys.json func ExampleDirectLineClient_RegenerateKeys_regenerateKeysForDirectLineChannelSite() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewDirectLineClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.RegenerateKeysChannelNameDirectLineChannel, armbotservice.SiteInfo{ + res, err := clientFactory.NewDirectLineClient().RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.RegenerateKeysChannelNameDirectLineChannel, armbotservice.SiteInfo{ Key: to.Ptr(armbotservice.KeyKey1), SiteName: to.Ptr("testSiteName"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // Location: to.Ptr("global"), + // Properties: &armbotservice.DirectLineChannel{ + // ChannelName: to.Ptr("DirectLineChannel"), + // Properties: &armbotservice.DirectLineChannelProperties{ + // Sites: []*armbotservice.DirectLineSite{ + // { + // IsEnabled: to.Ptr(true), + // IsV1Enabled: to.Ptr(true), + // IsV3Enabled: to.Ptr(true), + // Key: to.Ptr("key1"), + // Key2: to.Ptr("key2"), + // SiteID: to.Ptr("abcd"), + // SiteName: to.Ptr("Default Site"), + // }}, + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/WebChatRegenerateKeys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/WebChatRegenerateKeys.json func ExampleDirectLineClient_RegenerateKeys_regenerateKeysForWebChatChannelSite() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewDirectLineClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.RegenerateKeysChannelNameWebChatChannel, armbotservice.SiteInfo{ + res, err := clientFactory.NewDirectLineClient().RegenerateKeys(ctx, "OneResourceGroupName", "samplebotname", armbotservice.RegenerateKeysChannelNameWebChatChannel, armbotservice.SiteInfo{ Key: to.Ptr(armbotservice.KeyKey1), SiteName: to.Ptr("testSiteName"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BotChannel = armbotservice.BotChannel{ + // Location: to.Ptr("global"), + // Properties: &armbotservice.WebChatChannel{ + // ChannelName: to.Ptr("WebChatChannel"), + // Properties: &armbotservice.WebChatChannelProperties{ + // Sites: []*armbotservice.WebChatSite{ + // { + // IsEnabled: to.Ptr(true), + // IsWebchatPreviewEnabled: to.Ptr(true), + // Key: to.Ptr("key1"), + // Key2: to.Ptr("key2"), + // SiteID: to.Ptr("abcd"), + // SiteName: to.Ptr("Default Site"), + // }}, + // }, + // }, + // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/email_client.go b/sdk/resourcemanager/botservice/armbotservice/email_client.go index 4639e04bf8ca..a0d8dca4f44d 100644 --- a/sdk/resourcemanager/botservice/armbotservice/email_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/email_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // EmailClient contains the methods for the Email group. // Don't use this type directly, use NewEmailClient() instead. type EmailClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewEmailClient creates a new instance of EmailClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewEmailClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EmailClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".EmailClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &EmailClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateSignInURL - Creates an email channel sign in url for a Bot Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// options - EmailClientCreateSignInURLOptions contains the optional parameters for the EmailClient.CreateSignInURL method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - options - EmailClientCreateSignInURLOptions contains the optional parameters for the EmailClient.CreateSignInURL method. func (client *EmailClient) CreateSignInURL(ctx context.Context, resourceGroupName string, resourceName string, options *EmailClientCreateSignInURLOptions) (EmailClientCreateSignInURLResponse, error) { req, err := client.createSignInURLCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return EmailClientCreateSignInURLResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EmailClientCreateSignInURLResponse{}, err } @@ -91,7 +81,7 @@ func (client *EmailClient) createSignInURLCreateRequest(ctx context.Context, res return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/email_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/email_client_example_test.go index 0a5a817356b0..eefe5a663e05 100644 --- a/sdk/resourcemanager/botservice/armbotservice/email_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/email_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -16,21 +17,29 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CreateEmailSignInUrl.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CreateEmailSignInUrl.json func ExampleEmailClient_CreateSignInURL() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewEmailClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateSignInURL(ctx, "OneResourceGroupName", "samplebotname", nil) + res, err := clientFactory.NewEmailClient().CreateSignInURL(ctx, "OneResourceGroupName", "samplebotname", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CreateEmailSignInURLResponse = armbotservice.CreateEmailSignInURLResponse{ + // ID: to.Ptr("/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.BotService/botServices/samplebotname"), + // Location: to.Ptr("global"), + // Properties: &armbotservice.CreateEmailSignInURLResponseProperties{ + // URL: to.Ptr("https://token.botframework.com/api/oauth/signin?signin=XXX"), + // }, + // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/go.mod b/sdk/resourcemanager/botservice/armbotservice/go.mod index 36c42da8325b..a0bc53a12b5f 100644 --- a/sdk/resourcemanager/botservice/armbotservice/go.mod +++ b/sdk/resourcemanager/botservice/armbotservice/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotse go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/botservice/armbotservice/go.sum b/sdk/resourcemanager/botservice/armbotservice/go.sum index 8c0539b73123..8ba445a8c4da 100644 --- a/sdk/resourcemanager/botservice/armbotservice/go.sum +++ b/sdk/resourcemanager/botservice/armbotservice/go.sum @@ -1,30 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client.go b/sdk/resourcemanager/botservice/armbotservice/hostsettings_client.go index 8012a72cb2da..83c06d11b752 100644 --- a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/hostsettings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,45 +24,37 @@ import ( // HostSettingsClient contains the methods for the HostSettings group. // Don't use this type directly, use NewHostSettingsClient() instead. type HostSettingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewHostSettingsClient creates a new instance of HostSettingsClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewHostSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HostSettingsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".HostSettingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &HostSettingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get per subscription settings needed to host bot in compute resource such as Azure App Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// options - HostSettingsClientGetOptions contains the optional parameters for the HostSettingsClient.Get method. +// - options - HostSettingsClientGetOptions contains the optional parameters for the HostSettingsClient.Get method. func (client *HostSettingsClient) Get(ctx context.Context, options *HostSettingsClientGetOptions) (HostSettingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, options) if err != nil { return HostSettingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HostSettingsClientGetResponse{}, err } @@ -81,7 +71,7 @@ func (client *HostSettingsClient) getCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/hostsettings_client_example_test.go index 78988dbe926d..fb4ef845c7e7 100644 --- a/sdk/resourcemanager/botservice/armbotservice/hostsettings_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/hostsettings_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -16,21 +17,32 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetHostSettings.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetHostSettings.json func ExampleHostSettingsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewHostSettingsClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, nil) + res, err := clientFactory.NewHostSettingsClient().Get(ctx, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.HostSettingsResponse = armbotservice.HostSettingsResponse{ + // BotOpenIDMetadata: to.Ptr("https://login.botframework.com/v1/.well-known/openidconfiguration"), + // OAuthURL: to.Ptr("https://token.botframework.com/"), + // ToBotFromChannelOpenIDMetadataURL: to.Ptr("https://login.botframework.com/v1/.well-known/openidconfiguration"), + // ToBotFromChannelTokenIssuer: to.Ptr("https://api.botframework.com"), + // ToBotFromEmulatorOpenIDMetadataURL: to.Ptr("https://login.microsoftonline.com/botframework.com/v2.0/.well-known/openid-configuration"), + // ToChannelFromBotLoginURL: to.Ptr("https://login.microsoftonline.com/botframework.com"), + // ToChannelFromBotOAuthScope: to.Ptr("https://api.botframework.com"), + // ValidateAuthority: to.Ptr(true), + // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/models.go b/sdk/resourcemanager/botservice/armbotservice/models.go index 3ed7570606ac..a9d81ca2d98b 100644 --- a/sdk/resourcemanager/botservice/armbotservice/models.go +++ b/sdk/resourcemanager/botservice/armbotservice/models.go @@ -160,7 +160,7 @@ type BotConnectionClientGetOptions struct { // placeholder for future optional parameters } -// BotConnectionClientListByBotServiceOptions contains the optional parameters for the BotConnectionClient.ListByBotService +// BotConnectionClientListByBotServiceOptions contains the optional parameters for the BotConnectionClient.NewListByBotServicePager // method. type BotConnectionClientListByBotServiceOptions struct { // placeholder for future optional parameters @@ -321,12 +321,12 @@ type BotsClientGetOptions struct { // placeholder for future optional parameters } -// BotsClientListByResourceGroupOptions contains the optional parameters for the BotsClient.ListByResourceGroup method. +// BotsClientListByResourceGroupOptions contains the optional parameters for the BotsClient.NewListByResourceGroupPager method. type BotsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// BotsClientListOptions contains the optional parameters for the BotsClient.List method. +// BotsClientListOptions contains the optional parameters for the BotsClient.NewListPager method. type BotsClientListOptions struct { // placeholder for future optional parameters } @@ -422,7 +422,8 @@ type ChannelsClientGetOptions struct { // placeholder for future optional parameters } -// ChannelsClientListByResourceGroupOptions contains the optional parameters for the ChannelsClient.ListByResourceGroup method. +// ChannelsClientListByResourceGroupOptions contains the optional parameters for the ChannelsClient.NewListByResourceGroupPager +// method. type ChannelsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } @@ -1147,7 +1148,7 @@ type OperationEntity struct { Origin *string `json:"origin,omitempty"` // Additional properties. - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` } // OperationEntityListResult - The list of bot service operation response. @@ -1180,7 +1181,7 @@ type OperationResultsDescription struct { Status *OperationResultStatus `json:"status,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -1270,7 +1271,7 @@ type PrivateEndpointConnectionsClientGetOptions struct { // placeholder for future optional parameters } -// PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.List +// PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListPager // method. type PrivateEndpointConnectionsClientListOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/botservice/armbotservice/models_serde.go b/sdk/resourcemanager/botservice/armbotservice/models_serde.go index 4d186b46e03d..7759ee2876e8 100644 --- a/sdk/resourcemanager/botservice/armbotservice/models_serde.go +++ b/sdk/resourcemanager/botservice/armbotservice/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type AcsChatChannel. func (a AcsChatChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "AcsChatChannel" populate(objectMap, "etag", a.Etag) populate(objectMap, "location", a.Location) @@ -57,7 +57,7 @@ func (a *AcsChatChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlexaChannel. func (a AlexaChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "AlexaChannel" populate(objectMap, "etag", a.Etag) populate(objectMap, "location", a.Location) @@ -100,7 +100,7 @@ func (a *AlexaChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlexaChannelProperties. func (a AlexaChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alexaSkillId", a.AlexaSkillID) populate(objectMap, "isEnabled", a.IsEnabled) populate(objectMap, "serviceEndpointUri", a.ServiceEndpointURI) @@ -139,7 +139,7 @@ func (a *AlexaChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Bot. func (b Bot) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", b.Etag) populate(objectMap, "id", b.ID) populate(objectMap, "kind", b.Kind) @@ -202,7 +202,7 @@ func (b *Bot) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BotChannel. func (b BotChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", b.Etag) populate(objectMap, "id", b.ID) populate(objectMap, "kind", b.Kind) @@ -265,7 +265,7 @@ func (b *BotChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BotProperties. func (b BotProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allSettings", b.AllSettings) populate(objectMap, "appPasswordHint", b.AppPasswordHint) populate(objectMap, "cmekEncryptionStatus", b.CmekEncryptionStatus) @@ -428,7 +428,7 @@ func (b *BotProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BotResponseList. func (b BotResponseList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", b.NextLink) populate(objectMap, "value", b.Value) return json.Marshal(objectMap) @@ -459,7 +459,7 @@ func (b *BotResponseList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Channel. func (c Channel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = c.ChannelName populate(objectMap, "etag", c.Etag) populate(objectMap, "location", c.Location) @@ -498,7 +498,7 @@ func (c *Channel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ChannelResponseList. func (c ChannelResponseList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -529,7 +529,7 @@ func (c *ChannelResponseList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ChannelSettings. func (c ChannelSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "botId", c.BotID) populate(objectMap, "botIconUrl", c.BotIconURL) populate(objectMap, "channelDisplayName", c.ChannelDisplayName) @@ -592,7 +592,7 @@ func (c *ChannelSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequestBody. func (c CheckNameAvailabilityRequestBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", c.Name) populate(objectMap, "type", c.Type) return json.Marshal(objectMap) @@ -623,7 +623,7 @@ func (c *CheckNameAvailabilityRequestBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponseBody. func (c CheckNameAvailabilityResponseBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "absCode", c.AbsCode) populate(objectMap, "message", c.Message) populate(objectMap, "valid", c.Valid) @@ -658,7 +658,7 @@ func (c *CheckNameAvailabilityResponseBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionItemName. func (c ConnectionItemName) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", c.Name) return json.Marshal(objectMap) } @@ -685,7 +685,7 @@ func (c *ConnectionItemName) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionSetting. func (c ConnectionSetting) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", c.Etag) populate(objectMap, "id", c.ID) populate(objectMap, "kind", c.Kind) @@ -748,7 +748,7 @@ func (c *ConnectionSetting) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionSettingParameter. func (c ConnectionSettingParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "key", c.Key) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -779,7 +779,7 @@ func (c *ConnectionSettingParameter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionSettingProperties. func (c ConnectionSettingProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", c.ClientID) populate(objectMap, "clientSecret", c.ClientSecret) populate(objectMap, "parameters", c.Parameters) @@ -834,7 +834,7 @@ func (c *ConnectionSettingProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConnectionSettingResponseList. func (c ConnectionSettingResponseList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -865,7 +865,7 @@ func (c *ConnectionSettingResponseList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CreateEmailSignInURLResponse. func (c CreateEmailSignInURLResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "location", c.Location) populate(objectMap, "properties", c.Properties) @@ -900,7 +900,7 @@ func (c *CreateEmailSignInURLResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CreateEmailSignInURLResponseProperties. func (c CreateEmailSignInURLResponseProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "url", c.URL) return json.Marshal(objectMap) } @@ -927,7 +927,7 @@ func (c *CreateEmailSignInURLResponseProperties) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type DirectLineChannel. func (d DirectLineChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "DirectLineChannel" populate(objectMap, "etag", d.Etag) populate(objectMap, "location", d.Location) @@ -970,7 +970,7 @@ func (d *DirectLineChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DirectLineChannelProperties. func (d DirectLineChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "DirectLineEmbedCode", d.DirectLineEmbedCode) populate(objectMap, "extensionKey1", d.ExtensionKey1) populate(objectMap, "extensionKey2", d.ExtensionKey2) @@ -1009,7 +1009,7 @@ func (d *DirectLineChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DirectLineSite. func (d DirectLineSite) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "appId", d.AppID) populate(objectMap, "eTag", d.ETag) populate(objectMap, "isBlockUserUploadEnabled", d.IsBlockUserUploadEnabled) @@ -1108,7 +1108,7 @@ func (d *DirectLineSite) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DirectLineSpeechChannel. func (d DirectLineSpeechChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "DirectLineSpeechChannel" populate(objectMap, "etag", d.Etag) populate(objectMap, "location", d.Location) @@ -1151,7 +1151,7 @@ func (d *DirectLineSpeechChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DirectLineSpeechChannelProperties. func (d DirectLineSpeechChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cognitiveServiceRegion", d.CognitiveServiceRegion) populate(objectMap, "cognitiveServiceResourceId", d.CognitiveServiceResourceID) populate(objectMap, "cognitiveServiceSubscriptionKey", d.CognitiveServiceSubscriptionKey) @@ -1202,7 +1202,7 @@ func (d *DirectLineSpeechChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EmailChannel. func (e EmailChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "EmailChannel" populate(objectMap, "etag", e.Etag) populate(objectMap, "location", e.Location) @@ -1245,7 +1245,7 @@ func (e *EmailChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EmailChannelProperties. func (e EmailChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authMethod", e.AuthMethod) populate(objectMap, "emailAddress", e.EmailAddress) populate(objectMap, "isEnabled", e.IsEnabled) @@ -1288,7 +1288,7 @@ func (e *EmailChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Error. func (e Error) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -1315,7 +1315,7 @@ func (e *Error) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorBody. func (e ErrorBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", e.Code) populate(objectMap, "message", e.Message) return json.Marshal(objectMap) @@ -1346,7 +1346,7 @@ func (e *ErrorBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FacebookChannel. func (f FacebookChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "FacebookChannel" populate(objectMap, "etag", f.Etag) populate(objectMap, "location", f.Location) @@ -1389,7 +1389,7 @@ func (f *FacebookChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FacebookChannelProperties. func (f FacebookChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "appId", f.AppID) populate(objectMap, "appSecret", f.AppSecret) populate(objectMap, "callbackUrl", f.CallbackURL) @@ -1436,7 +1436,7 @@ func (f *FacebookChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FacebookPage. func (f FacebookPage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accessToken", f.AccessToken) populate(objectMap, "id", f.ID) return json.Marshal(objectMap) @@ -1467,7 +1467,7 @@ func (f *FacebookPage) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HostSettingsResponse. func (h HostSettingsResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "BotOpenIdMetadata", h.BotOpenIDMetadata) populate(objectMap, "OAuthUrl", h.OAuthURL) populate(objectMap, "ToBotFromChannelOpenIdMetadataUrl", h.ToBotFromChannelOpenIDMetadataURL) @@ -1522,7 +1522,7 @@ func (h *HostSettingsResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type KikChannel. func (k KikChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "KikChannel" populate(objectMap, "etag", k.Etag) populate(objectMap, "location", k.Location) @@ -1565,7 +1565,7 @@ func (k *KikChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type KikChannelProperties. func (k KikChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "apiKey", k.APIKey) populate(objectMap, "isEnabled", k.IsEnabled) populate(objectMap, "isValidated", k.IsValidated) @@ -1604,7 +1604,7 @@ func (k *KikChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LineChannel. func (l LineChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "LineChannel" populate(objectMap, "etag", l.Etag) populate(objectMap, "location", l.Location) @@ -1647,7 +1647,7 @@ func (l *LineChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LineChannelProperties. func (l LineChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "callbackUrl", l.CallbackURL) populate(objectMap, "isValidated", l.IsValidated) populate(objectMap, "lineRegistrations", l.LineRegistrations) @@ -1682,7 +1682,7 @@ func (l *LineChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LineRegistration. func (l LineRegistration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "channelAccessToken", l.ChannelAccessToken) populate(objectMap, "channelSecret", l.ChannelSecret) populate(objectMap, "generatedId", l.GeneratedID) @@ -1717,7 +1717,7 @@ func (l *LineRegistration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListChannelWithKeysResponse. func (l ListChannelWithKeysResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "changedTime", l.ChangedTime) populate(objectMap, "entityTag", l.EntityTag) populate(objectMap, "etag", l.Etag) @@ -1800,7 +1800,7 @@ func (l *ListChannelWithKeysResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type M365Extensions. func (m M365Extensions) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "M365Extensions" populate(objectMap, "etag", m.Etag) populate(objectMap, "location", m.Location) @@ -1839,7 +1839,7 @@ func (m *M365Extensions) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MsTeamsChannel. func (m MsTeamsChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "MsTeamsChannel" populate(objectMap, "etag", m.Etag) populate(objectMap, "location", m.Location) @@ -1882,7 +1882,7 @@ func (m *MsTeamsChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MsTeamsChannelProperties. func (m MsTeamsChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "acceptedTerms", m.AcceptedTerms) populate(objectMap, "callingWebhook", m.CallingWebhook) populate(objectMap, "deploymentEnvironment", m.DeploymentEnvironment) @@ -1929,7 +1929,7 @@ func (m *MsTeamsChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Omnichannel. func (o Omnichannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "Omnichannel" populate(objectMap, "etag", o.Etag) populate(objectMap, "location", o.Location) @@ -1968,7 +1968,7 @@ func (o *Omnichannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplayInfo. func (o OperationDisplayInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -2007,7 +2007,7 @@ func (o *OperationDisplayInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationEntity. func (o OperationEntity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "name", o.Name) populate(objectMap, "origin", o.Origin) @@ -2046,7 +2046,7 @@ func (o *OperationEntity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationEntityListResult. func (o OperationEntityListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -2077,7 +2077,7 @@ func (o *OperationEntityListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationResultsDescription. func (o OperationResultsDescription) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", o.ID) populate(objectMap, "name", o.Name) populateTimeRFC3339(objectMap, "startTime", o.StartTime) @@ -2116,7 +2116,7 @@ func (o *OperationResultsDescription) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OutlookChannel. func (o OutlookChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "OutlookChannel" populate(objectMap, "etag", o.Etag) populate(objectMap, "location", o.Location) @@ -2155,7 +2155,7 @@ func (o *OutlookChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpoint. func (p PrivateEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) return json.Marshal(objectMap) } @@ -2182,7 +2182,7 @@ func (p *PrivateEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) @@ -2221,7 +2221,7 @@ func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -2248,7 +2248,7 @@ func (p *PrivateEndpointConnectionListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupIds", p.GroupIDs) populate(objectMap, "privateEndpoint", p.PrivateEndpoint) populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) @@ -2287,7 +2287,7 @@ func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "properties", p.Properties) @@ -2326,7 +2326,7 @@ func (p *PrivateLinkResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceBase. func (p PrivateLinkResourceBase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "type", p.Type) @@ -2361,7 +2361,7 @@ func (p *PrivateLinkResourceBase) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -2388,7 +2388,7 @@ func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupId", p.GroupID) populate(objectMap, "requiredMembers", p.RequiredMembers) populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) @@ -2423,7 +2423,7 @@ func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionsRequired", p.ActionsRequired) populate(objectMap, "description", p.Description) populate(objectMap, "status", p.Status) @@ -2458,7 +2458,7 @@ func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type QnAMakerEndpointKeysRequestBody. func (q QnAMakerEndpointKeysRequestBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authkey", q.Authkey) populate(objectMap, "hostname", q.Hostname) return json.Marshal(objectMap) @@ -2489,7 +2489,7 @@ func (q *QnAMakerEndpointKeysRequestBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type QnAMakerEndpointKeysResponse. func (q QnAMakerEndpointKeysResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "installedVersion", q.InstalledVersion) populate(objectMap, "lastStableVersion", q.LastStableVersion) populate(objectMap, "primaryEndpointKey", q.PrimaryEndpointKey) @@ -2528,7 +2528,7 @@ func (q *QnAMakerEndpointKeysResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "etag", r.Etag) populate(objectMap, "id", r.ID) populate(objectMap, "kind", r.Kind) @@ -2587,7 +2587,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKU. func (s SKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "tier", s.Tier) return json.Marshal(objectMap) @@ -2618,7 +2618,7 @@ func (s *SKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SearchAssistant. func (s SearchAssistant) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "SearchAssistant" populate(objectMap, "etag", s.Etag) populate(objectMap, "location", s.Location) @@ -2657,7 +2657,7 @@ func (s *SearchAssistant) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceProvider. func (s ServiceProvider) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", s.Properties) return json.Marshal(objectMap) } @@ -2684,7 +2684,7 @@ func (s *ServiceProvider) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceProviderParameter. func (s ServiceProviderParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "default", s.Default) populate(objectMap, "description", s.Description) populate(objectMap, "displayName", s.DisplayName) @@ -2735,7 +2735,7 @@ func (s *ServiceProviderParameter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceProviderParameterMetadata. func (s ServiceProviderParameterMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "constraints", s.Constraints) return json.Marshal(objectMap) } @@ -2762,7 +2762,7 @@ func (s *ServiceProviderParameterMetadata) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceProviderParameterMetadataConstraints. func (s ServiceProviderParameterMetadataConstraints) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "required", s.Required) return json.Marshal(objectMap) } @@ -2789,7 +2789,7 @@ func (s *ServiceProviderParameterMetadataConstraints) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type ServiceProviderProperties. func (s ServiceProviderProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "devPortalUrl", s.DevPortalURL) populate(objectMap, "displayName", s.DisplayName) populate(objectMap, "id", s.ID) @@ -2836,7 +2836,7 @@ func (s *ServiceProviderProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServiceProviderResponseList. func (s ServiceProviderResponseList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -2867,7 +2867,7 @@ func (s *ServiceProviderResponseList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Site. func (s Site) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "appId", s.AppID) populate(objectMap, "eTag", s.ETag) populate(objectMap, "isBlockUserUploadEnabled", s.IsBlockUserUploadEnabled) @@ -2966,7 +2966,7 @@ func (s *Site) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SiteInfo. func (s SiteInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "key", s.Key) populate(objectMap, "siteName", s.SiteName) return json.Marshal(objectMap) @@ -2997,7 +2997,7 @@ func (s *SiteInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SkypeChannel. func (s SkypeChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "SkypeChannel" populate(objectMap, "etag", s.Etag) populate(objectMap, "location", s.Location) @@ -3040,7 +3040,7 @@ func (s *SkypeChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SkypeChannelProperties. func (s SkypeChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "callingWebHook", s.CallingWebHook) populate(objectMap, "enableCalling", s.EnableCalling) populate(objectMap, "enableGroups", s.EnableGroups) @@ -3103,7 +3103,7 @@ func (s *SkypeChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SlackChannel. func (s SlackChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "SlackChannel" populate(objectMap, "etag", s.Etag) populate(objectMap, "location", s.Location) @@ -3146,7 +3146,7 @@ func (s *SlackChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SlackChannelProperties. func (s SlackChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", s.ClientID) populate(objectMap, "clientSecret", s.ClientSecret) populate(objectMap, "isEnabled", s.IsEnabled) @@ -3213,7 +3213,7 @@ func (s *SlackChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmsChannel. func (s SmsChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "SmsChannel" populate(objectMap, "etag", s.Etag) populate(objectMap, "location", s.Location) @@ -3256,7 +3256,7 @@ func (s *SmsChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmsChannelProperties. func (s SmsChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accountSID", s.AccountSID) populate(objectMap, "authToken", s.AuthToken) populate(objectMap, "isEnabled", s.IsEnabled) @@ -3299,7 +3299,7 @@ func (s *SmsChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TelegramChannel. func (t TelegramChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "TelegramChannel" populate(objectMap, "etag", t.Etag) populate(objectMap, "location", t.Location) @@ -3342,7 +3342,7 @@ func (t *TelegramChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TelegramChannelProperties. func (t TelegramChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "accessToken", t.AccessToken) populate(objectMap, "isEnabled", t.IsEnabled) populate(objectMap, "isValidated", t.IsValidated) @@ -3377,7 +3377,7 @@ func (t *TelegramChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TelephonyChannel. func (t TelephonyChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "TelephonyChannel" populate(objectMap, "etag", t.Etag) populate(objectMap, "location", t.Location) @@ -3420,7 +3420,7 @@ func (t *TelephonyChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TelephonyChannelProperties. func (t TelephonyChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "apiConfigurations", t.APIConfigurations) populate(objectMap, "cognitiveServiceRegion", t.CognitiveServiceRegion) populate(objectMap, "cognitiveServiceSubscriptionKey", t.CognitiveServiceSubscriptionKey) @@ -3471,7 +3471,7 @@ func (t *TelephonyChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TelephonyChannelResourceAPIConfiguration. func (t TelephonyChannelResourceAPIConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cognitiveServiceRegion", t.CognitiveServiceRegion) populate(objectMap, "cognitiveServiceResourceId", t.CognitiveServiceResourceID) populate(objectMap, "cognitiveServiceSubscriptionKey", t.CognitiveServiceSubscriptionKey) @@ -3518,7 +3518,7 @@ func (t *TelephonyChannelResourceAPIConfiguration) UnmarshalJSON(data []byte) er // MarshalJSON implements the json.Marshaller interface for type TelephonyPhoneNumbers. func (t TelephonyPhoneNumbers) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "acsEndpoint", t.AcsEndpoint) populate(objectMap, "acsResourceId", t.AcsResourceID) populate(objectMap, "acsSecret", t.AcsSecret) @@ -3581,7 +3581,7 @@ func (t *TelephonyPhoneNumbers) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WebChatChannel. func (w WebChatChannel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["channelName"] = "WebChatChannel" populate(objectMap, "etag", w.Etag) populate(objectMap, "location", w.Location) @@ -3624,7 +3624,7 @@ func (w *WebChatChannel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WebChatChannelProperties. func (w WebChatChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "sites", w.Sites) populate(objectMap, "webChatEmbedCode", w.WebChatEmbedCode) return json.Marshal(objectMap) @@ -3655,7 +3655,7 @@ func (w *WebChatChannelProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WebChatSite. func (w WebChatSite) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "appId", w.AppID) populate(objectMap, "eTag", w.ETag) populate(objectMap, "isBlockUserUploadEnabled", w.IsBlockUserUploadEnabled) @@ -3752,7 +3752,7 @@ func (w *WebChatSite) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -3762,7 +3762,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/botservice/armbotservice/operationresults_client.go b/sdk/resourcemanager/botservice/armbotservice/operationresults_client.go index 06b78a64d57d..e5096bad95f1 100644 --- a/sdk/resourcemanager/botservice/armbotservice/operationresults_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/operationresults_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,62 +24,55 @@ import ( // OperationResultsClient contains the methods for the OperationResults group. // Don't use this type directly, use NewOperationResultsClient() instead. type OperationResultsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOperationResultsClient creates a new instance of OperationResultsClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationResultsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationResultsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginGet - Get the operation result for a long running operation. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// operationResultID - The ID of the operation result to get. -// options - OperationResultsClientBeginGetOptions contains the optional parameters for the OperationResultsClient.BeginGet -// method. +// - operationResultID - The ID of the operation result to get. +// - options - OperationResultsClientBeginGetOptions contains the optional parameters for the OperationResultsClient.BeginGet +// method. func (client *OperationResultsClient) BeginGet(ctx context.Context, operationResultID string, options *OperationResultsClientBeginGetOptions) (*runtime.Poller[OperationResultsClientGetResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.get(ctx, operationResultID, options) if err != nil { return nil, err } - return runtime.NewPoller[OperationResultsClientGetResponse](resp, client.pl, nil) + return runtime.NewPoller[OperationResultsClientGetResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[OperationResultsClientGetResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OperationResultsClientGetResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Get - Get the operation result for a long running operation. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 func (client *OperationResultsClient) get(ctx context.Context, operationResultID string, options *OperationResultsClientBeginGetOptions) (*http.Response, error) { req, err := client.getCreateRequest(ctx, operationResultID, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -102,7 +93,7 @@ func (client *OperationResultsClient) getCreateRequest(ctx context.Context, oper return nil, errors.New("parameter operationResultID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationResultId}", url.PathEscape(operationResultID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/operationresults_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/operationresults_client_example_test.go index 8825b8ff6fca..46e0be02ce7a 100644 --- a/sdk/resourcemanager/botservice/armbotservice/operationresults_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/operationresults_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -16,18 +17,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/OperationResultsGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/OperationResultsGet.json func ExampleOperationResultsClient_BeginGet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewOperationResultsClient("subid", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginGet(ctx, "exampleid", nil) + poller, err := clientFactory.NewOperationResultsClient().BeginGet(ctx, "exampleid", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -35,6 +36,13 @@ func ExampleOperationResultsClient_BeginGet() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationResultsDescription = armbotservice.OperationResultsDescription{ + // Name: to.Ptr("servicename"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.BotService/locations/westus/operationresults/exampleid"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T06:03:30.2716301Z"); return t}()), + // Status: to.Ptr(armbotservice.OperationResultStatusRequested), + // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/operations_client.go b/sdk/resourcemanager/botservice/armbotservice/operations_client.go index 025ad1820e56..33a677ddb495 100644 --- a/sdk/resourcemanager/botservice/armbotservice/operations_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,35 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all the available BotService operations. +// // Generated from API version 2022-09-15 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.BotService/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go index b081eef7ebda..0118d988c3f6 100644 --- a/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/operations_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -16,26 +17,70 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetOperations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetOperations.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewOperationsClient(cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationEntityListResult = armbotservice.OperationEntityListResult{ + // Value: []*armbotservice.OperationEntity{ + // { + // Name: to.Ptr("Microsoft.BotService/botService/read"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Read Bot Service"), + // Operation: to.Ptr("Read Bot Service"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.BotService/botService/write"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Writes Bot Service"), + // Operation: to.Ptr("Write Bot Service"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.BotService/botService/delete"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Deletes Bot Service"), + // Operation: to.Ptr("Delete Bot Service"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.BotService/botService/botName/read"), + // Display: &armbotservice.OperationDisplayInfo{ + // Description: to.Ptr("Check bot name availability"), + // Operation: to.Ptr("Check bot name availability"), + // Provider: to.Ptr("Microsoft Bot Service"), + // Resource: to.Ptr("Bot Service name availability"), + // }, + // Origin: to.Ptr("user,system"), + // }}, + // } } } diff --git a/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go b/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go index d6dc3ce995a3..48835e7262c8 100644 --- a/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go +++ b/sdk/resourcemanager/botservice/armbotservice/polymorphic_helpers.go @@ -15,7 +15,7 @@ func unmarshalChannelClassification(rawMsg json.RawMessage) (ChannelClassificati if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go index d1cb4f4cc274..5cf42b963209 100644 --- a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,50 +24,42 @@ import ( // PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. // Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. type PrivateEndpointConnectionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateEndpointConnectionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Update the state of specified private endpoint connection associated with the Bot. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource -// properties - The private endpoint connection properties. -// options - PrivateEndpointConnectionsClientCreateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Create -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - properties - The private endpoint connection properties. +// - options - PrivateEndpointConnectionsClientCreateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Create +// method. func (client *PrivateEndpointConnectionsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOptions) (PrivateEndpointConnectionsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties, options) if err != nil { return PrivateEndpointConnectionsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientCreateResponse{}, err } @@ -98,7 +88,7 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(ctx context. return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,18 +110,19 @@ func (client *PrivateEndpointConnectionsClient) createHandleResponse(resp *http. // Delete - Deletes the specified private endpoint connection associated with the Bot. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource -// options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete +// method. func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientDeleteOptions) (PrivateEndpointConnectionsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientDeleteResponse{}, err } @@ -160,7 +151,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -173,18 +164,19 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Gets the specified private endpoint connection associated with the Bot. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource -// options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - privateEndpointConnectionName - The name of the private endpoint connection associated with the Azure resource +// - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get +// method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } @@ -213,7 +205,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,11 +226,12 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res } // NewListPager - List all the private endpoint connections associated with the Bot. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.List -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListPager +// method. func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName string, resourceName string, options *PrivateEndpointConnectionsClientListOptions) *runtime.Pager[PrivateEndpointConnectionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateEndpointConnectionsClientListResponse]{ More: func(page PrivateEndpointConnectionsClientListResponse) bool { @@ -249,7 +242,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } @@ -276,7 +269,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go index 9be3cc0ad7b5..458d69ebacd2 100644 --- a/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/privateendpointconnections_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -17,61 +18,114 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateEndpointConnections.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateEndpointConnections.json func ExamplePrivateEndpointConnectionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("res6977", "sto2527", nil) + pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListPager("res6977", "sto2527", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.PrivateEndpointConnectionListResult = armbotservice.PrivateEndpointConnectionListResult{ + // Value: []*armbotservice.PrivateEndpointConnection{ + // { + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest02"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetPrivateEndpointConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetPrivateEndpointConnection.json func ExamplePrivateEndpointConnectionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armbotservice.PrivateEndpointConnection{ + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutPrivateEndpointConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutPrivateEndpointConnection.json func ExamplePrivateEndpointConnectionsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", armbotservice.PrivateEndpointConnection{ + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Create(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", armbotservice.PrivateEndpointConnection{ Properties: &armbotservice.PrivateEndpointConnectionProperties{ PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ Description: to.Ptr("Auto-Approved"), @@ -82,22 +136,39 @@ func ExamplePrivateEndpointConnectionsClient_Create() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateEndpointConnection = armbotservice.PrivateEndpointConnection{ + // Name: to.Ptr("{privateEndpointConnectionName}"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateEndpointConnections"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.BotService/botServices/sto288/privateEndpointConnections/{privateEndpointConnectionName}"), + // Properties: &armbotservice.PrivateEndpointConnectionProperties{ + // PrivateEndpoint: &armbotservice.PrivateEndpoint{ + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Network/privateEndpoints/petest01"), + // }, + // PrivateLinkServiceConnectionState: &armbotservice.PrivateLinkServiceConnectionState{ + // Description: to.Ptr("Auto-Approved"), + // ActionsRequired: to.Ptr("None"), + // Status: to.Ptr(armbotservice.PrivateEndpointServiceConnectionStatusApproved), + // }, + // ProvisioningState: to.Ptr(armbotservice.PrivateEndpointConnectionProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeletePrivateEndpointConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeletePrivateEndpointConnection.json func ExamplePrivateEndpointConnectionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) + _, err = clientFactory.NewPrivateEndpointConnectionsClient().Delete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client.go b/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client.go index 1138aa3e9e1e..c8bf6018f51b 100644 --- a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. // Don't use this type directly, use NewPrivateLinkResourcesClient() instead. type PrivateLinkResourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateLinkResourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // ListByBotResource - Gets the private link resources that need to be created for a Bot. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// resourceGroupName - The name of the Bot resource group in the user subscription. -// resourceName - The name of the Bot resource. -// options - PrivateLinkResourcesClientListByBotResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByBotResource -// method. +// - resourceGroupName - The name of the Bot resource group in the user subscription. +// - resourceName - The name of the Bot resource. +// - options - PrivateLinkResourcesClientListByBotResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByBotResource +// method. func (client *PrivateLinkResourcesClient) ListByBotResource(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateLinkResourcesClientListByBotResourceOptions) (PrivateLinkResourcesClientListByBotResourceResponse, error) { req, err := client.listByBotResourceCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return PrivateLinkResourcesClientListByBotResourceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientListByBotResourceResponse{}, err } @@ -92,7 +82,7 @@ func (client *PrivateLinkResourcesClient) listByBotResourceCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client_example_test.go index 8d383357b9a8..2ae0504011df 100644 --- a/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/privatelinkresources_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -16,21 +17,37 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateLinkResources.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateLinkResources.json func ExamplePrivateLinkResourcesClient_ListByBotResource() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewPrivateLinkResourcesClient("{subscription-id}", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListByBotResource(ctx, "res6977", "sto2527", nil) + res, err := clientFactory.NewPrivateLinkResourcesClient().ListByBotResource(ctx, "res6977", "sto2527", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PrivateLinkResourceListResult = armbotservice.PrivateLinkResourceListResult{ + // Value: []*armbotservice.PrivateLinkResource{ + // { + // Name: to.Ptr("resource1"), + // Type: to.Ptr("Microsoft.BotService/botServices/privateLinkResources"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res6977/providers/Microsoft.BotService/botServices/sto2527/privateLinkResources/resource1"), + // Properties: &armbotservice.PrivateLinkResourceProperties{ + // GroupID: to.Ptr("bot"), + // RequiredMembers: []*string{ + // to.Ptr("bot")}, + // RequiredZoneNames: []*string{ + // to.Ptr("privatelink.botframework.com")}, + // }, + // }}, + // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client.go b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client.go index 6a55e13c1ddb..14b2d3ad19b1 100644 --- a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client.go +++ b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,47 +24,39 @@ import ( // QnAMakerEndpointKeysClient contains the methods for the QnAMakerEndpointKeys group. // Don't use this type directly, use NewQnAMakerEndpointKeysClient() instead. type QnAMakerEndpointKeysClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewQnAMakerEndpointKeysClient creates a new instance of QnAMakerEndpointKeysClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewQnAMakerEndpointKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QnAMakerEndpointKeysClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".QnAMakerEndpointKeysClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &QnAMakerEndpointKeysClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Lists the QnA Maker endpoint keys // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-15 -// parameters - The request body parameters to provide for the check name availability request -// options - QnAMakerEndpointKeysClientGetOptions contains the optional parameters for the QnAMakerEndpointKeysClient.Get -// method. +// - parameters - The request body parameters to provide for the check name availability request +// - options - QnAMakerEndpointKeysClientGetOptions contains the optional parameters for the QnAMakerEndpointKeysClient.Get +// method. func (client *QnAMakerEndpointKeysClient) Get(ctx context.Context, parameters QnAMakerEndpointKeysRequestBody, options *QnAMakerEndpointKeysClientGetOptions) (QnAMakerEndpointKeysClientGetResponse, error) { req, err := client.getCreateRequest(ctx, parameters, options) if err != nil { return QnAMakerEndpointKeysClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return QnAMakerEndpointKeysClientGetResponse{}, err } @@ -83,7 +73,7 @@ func (client *QnAMakerEndpointKeysClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client_example_test.go b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client_example_test.go index 992d2f3b8eaa..3837e13fea78 100644 --- a/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client_example_test.go +++ b/sdk/resourcemanager/botservice/armbotservice/qnamakerendpointkeys_client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armbotservice_test @@ -17,24 +18,31 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/botservice/armbotservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListQnAMakerEndpointKeys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e7bf3adfa2d5e5cdbb804eec35279501794f461c/specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListQnAMakerEndpointKeys.json func ExampleQnAMakerEndpointKeysClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armbotservice.NewQnAMakerEndpointKeysClient("subscription-id", cred, nil) + clientFactory, err := armbotservice.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, armbotservice.QnAMakerEndpointKeysRequestBody{ + res, err := clientFactory.NewQnAMakerEndpointKeysClient().Get(ctx, armbotservice.QnAMakerEndpointKeysRequestBody{ Authkey: to.Ptr("testAuthKey"), Hostname: to.Ptr("https://xxx.cognitiveservices.azure.com/"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.QnAMakerEndpointKeysResponse = armbotservice.QnAMakerEndpointKeysResponse{ + // InstalledVersion: to.Ptr("4.1.0"), + // LastStableVersion: to.Ptr("4.2.0"), + // PrimaryEndpointKey: to.Ptr("sample_primaryEndpointKey"), + // SecondaryEndpointKey: to.Ptr("sample_secondaryEndpointKey"), + // } } diff --git a/sdk/resourcemanager/botservice/armbotservice/response_types.go b/sdk/resourcemanager/botservice/armbotservice/response_types.go index 685de61f337c..d854a0744848 100644 --- a/sdk/resourcemanager/botservice/armbotservice/response_types.go +++ b/sdk/resourcemanager/botservice/armbotservice/response_types.go @@ -24,7 +24,7 @@ type BotConnectionClientGetResponse struct { ConnectionSetting } -// BotConnectionClientListByBotServiceResponse contains the response from method BotConnectionClient.ListByBotService. +// BotConnectionClientListByBotServiceResponse contains the response from method BotConnectionClient.NewListByBotServicePager. type BotConnectionClientListByBotServiceResponse struct { ConnectionSettingResponseList } @@ -64,12 +64,12 @@ type BotsClientGetResponse struct { Bot } -// BotsClientListByResourceGroupResponse contains the response from method BotsClient.ListByResourceGroup. +// BotsClientListByResourceGroupResponse contains the response from method BotsClient.NewListByResourceGroupPager. type BotsClientListByResourceGroupResponse struct { BotResponseList } -// BotsClientListResponse contains the response from method BotsClient.List. +// BotsClientListResponse contains the response from method BotsClient.NewListPager. type BotsClientListResponse struct { BotResponseList } @@ -94,7 +94,7 @@ type ChannelsClientGetResponse struct { BotChannel } -// ChannelsClientListByResourceGroupResponse contains the response from method ChannelsClient.ListByResourceGroup. +// ChannelsClientListByResourceGroupResponse contains the response from method ChannelsClient.NewListByResourceGroupPager. type ChannelsClientListByResourceGroupResponse struct { ChannelResponseList } @@ -124,12 +124,12 @@ type HostSettingsClientGetResponse struct { HostSettingsResponse } -// OperationResultsClientGetResponse contains the response from method OperationResultsClient.Get. +// OperationResultsClientGetResponse contains the response from method OperationResultsClient.BeginGet. type OperationResultsClientGetResponse struct { OperationResultsDescription } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationEntityListResult } @@ -149,7 +149,7 @@ type PrivateEndpointConnectionsClientGetResponse struct { PrivateEndpointConnection } -// PrivateEndpointConnectionsClientListResponse contains the response from method PrivateEndpointConnectionsClient.List. +// PrivateEndpointConnectionsClientListResponse contains the response from method PrivateEndpointConnectionsClient.NewListPager. type PrivateEndpointConnectionsClientListResponse struct { PrivateEndpointConnectionListResult } diff --git a/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go b/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go index b5992697d3ac..4e7d2d01999c 100644 --- a/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go +++ b/sdk/resourcemanager/botservice/armbotservice/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/CHANGELOG.md b/sdk/resourcemanager/changeanalysis/armchangeanalysis/CHANGELOG.md index a219ed8d78ca..997fb077fcc3 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/CHANGELOG.md +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armchangeanalysis` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/README.md b/sdk/resourcemanager/changeanalysis/armchangeanalysis/README.md index f3d4e41deacd..26633799d6a7 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/README.md +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Change Analysis modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Change Analysis module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armchangeanalysis.NewChangesClient(, cred, nil) +clientFactory, err := armchangeanalysis.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armchangeanalysis.NewChangesClient(, cred, &options) +clientFactory, err := armchangeanalysis.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewChangesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/autorest.md b/sdk/resourcemanager/changeanalysis/armchangeanalysis/autorest.md index 0f4808db034b..e1b0c6dc7b73 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/autorest.md +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/changeanalysis/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/changeanalysis/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_changes_client.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/changes_client.go similarity index 82% rename from sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_changes_client.go rename to sdk/resourcemanager/changeanalysis/armchangeanalysis/changes_client.go index 67fbfa4bbc1c..dc51ed8d7673 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_changes_client.go +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/changes_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchangeanalysis @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,44 +25,35 @@ import ( // ChangesClient contains the methods for the Changes group. // Don't use this type directly, use NewChangesClient() instead. type ChangesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewChangesClient creates a new instance of ChangesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewChangesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ChangesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ChangesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ChangesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListChangesByResourceGroupPager - List the changes of a resource group within the specified time range. Customer data // will always be masked. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-04-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// startTime - Specifies the start time of the changes request. -// endTime - Specifies the end time of the changes request. -// options - ChangesClientListChangesByResourceGroupOptions contains the optional parameters for the ChangesClient.ListChangesByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - startTime - Specifies the start time of the changes request. +// - endTime - Specifies the end time of the changes request. +// - options - ChangesClientListChangesByResourceGroupOptions contains the optional parameters for the ChangesClient.NewListChangesByResourceGroupPager +// method. func (client *ChangesClient) NewListChangesByResourceGroupPager(resourceGroupName string, startTime time.Time, endTime time.Time, options *ChangesClientListChangesByResourceGroupOptions) *runtime.Pager[ChangesClientListChangesByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ChangesClientListChangesByResourceGroupResponse]{ More: func(page ChangesClientListChangesByResourceGroupResponse) bool { @@ -80,7 +70,7 @@ func (client *ChangesClient) NewListChangesByResourceGroupPager(resourceGroupNam if err != nil { return ChangesClientListChangesByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChangesClientListChangesByResourceGroupResponse{}, err } @@ -103,7 +93,7 @@ func (client *ChangesClient) listChangesByResourceGroupCreateRequest(ctx context return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -130,12 +120,12 @@ func (client *ChangesClient) listChangesByResourceGroupHandleResponse(resp *http // NewListChangesBySubscriptionPager - List the changes of a subscription within the specified time range. Customer data will // always be masked. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-04-01 -// startTime - Specifies the start time of the changes request. -// endTime - Specifies the end time of the changes request. -// options - ChangesClientListChangesBySubscriptionOptions contains the optional parameters for the ChangesClient.ListChangesBySubscription -// method. +// - startTime - Specifies the start time of the changes request. +// - endTime - Specifies the end time of the changes request. +// - options - ChangesClientListChangesBySubscriptionOptions contains the optional parameters for the ChangesClient.NewListChangesBySubscriptionPager +// method. func (client *ChangesClient) NewListChangesBySubscriptionPager(startTime time.Time, endTime time.Time, options *ChangesClientListChangesBySubscriptionOptions) *runtime.Pager[ChangesClientListChangesBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ChangesClientListChangesBySubscriptionResponse]{ More: func(page ChangesClientListChangesBySubscriptionResponse) bool { @@ -152,7 +142,7 @@ func (client *ChangesClient) NewListChangesBySubscriptionPager(startTime time.Ti if err != nil { return ChangesClientListChangesBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChangesClientListChangesBySubscriptionResponse{}, err } @@ -171,7 +161,7 @@ func (client *ChangesClient) listChangesBySubscriptionCreateRequest(ctx context. return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/changes_client_example_test.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/changes_client_example_test.go new file mode 100644 index 000000000000..2b3b8033512c --- /dev/null +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/changes_client_example_test.go @@ -0,0 +1,172 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchangeanalysis_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armchangeanalysis" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ChangesListChangesByResourceGroup.json +func ExampleChangesClient_NewListChangesByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchangeanalysis.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewChangesClient().NewListChangesByResourceGroupPager("MyResourceGroup", func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-25T12:09:03.141Z"); return t }(), func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T12:09:03.141Z"); return t }(), &armchangeanalysis.ChangesClientListChangesByResourceGroupOptions{SkipToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ChangeList = armchangeanalysis.ChangeList{ + // Value: []*armchangeanalysis.Change{ + // { + // Name: to.Ptr("ARG_23fa00fd-dda0-4268-b482-2076825cf165_970d8c6d-6b78-4270-92ef-88d5aa2b5f0b_132316363294700000_132316498613900000"), + // Type: to.Ptr("Microsoft.ChangeAnalysis/changes"), + // ID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup"), + // Properties: &armchangeanalysis.ChangeProperties{ + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // InitiatedByList: []*string{ + // to.Ptr("ellen@contoso.com")}, + // PropertyChanges: []*armchangeanalysis.PropertyChange{ + // { + // Description: to.Ptr("The tag of the resource"), + // ChangeCategory: to.Ptr(armchangeanalysis.ChangeCategoryUser), + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // DisplayName: to.Ptr("tags.resourceGroupTag"), + // IsDataMasked: to.Ptr(false), + // JSONPath: to.Ptr("tags.resourceGroupTag"), + // Level: to.Ptr(armchangeanalysis.LevelImportant), + // NewValue: to.Ptr("new tag value"), + // OldValue: to.Ptr("old tag value"), + // }}, + // ResourceID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup"), + // TimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T02:17:41.39Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("AST_b2ecd7ec-00dd-4d44-bd19-fefc88790c05_da36e22e-f541-44bd-8d89-8f10a27af4ad_132592897881782408_132592957873393845"), + // Type: to.Ptr("Microsoft.ChangeAnalysis/changes"), + // ID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite/extensions/AppStateTracker/providers/Microsoft.ChangeAnalysis/changes/AST_b2ecd7ec-00dd-4d44-bd19-fefc88790c05_da36e22e-f541-44bd-8d89-8f10a27af4ad_132592897881782408_132592957873393845"), + // Properties: &armchangeanalysis.ChangeProperties{ + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // InitiatedByList: []*string{ + // to.Ptr("ellen@contoso.com")}, + // PropertyChanges: []*armchangeanalysis.PropertyChange{ + // { + // Description: to.Ptr("Application setting"), + // ChangeCategory: to.Ptr(armchangeanalysis.ChangeCategoryUser), + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // DisplayName: to.Ptr("APPSETTING_DB_CONNSTR"), + // IsDataMasked: to.Ptr(true), + // JSONPath: to.Ptr("environment.environmentVariables.APPSETTING_DB_CONNSTR"), + // Level: to.Ptr(armchangeanalysis.LevelImportant), + // NewValue: to.Ptr("***New Value Hidden***"), + // OldValue: to.Ptr("***Old Value Hidden***"), + // }}, + // ResourceID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite"), + // TimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T02:17:41.39Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ChangesListChangesBySubscription.json +func ExampleChangesClient_NewListChangesBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchangeanalysis.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewChangesClient().NewListChangesBySubscriptionPager(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-25T12:09:03.141Z"); return t }(), func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T12:09:03.141Z"); return t }(), &armchangeanalysis.ChangesClientListChangesBySubscriptionOptions{SkipToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ChangeList = armchangeanalysis.ChangeList{ + // Value: []*armchangeanalysis.Change{ + // { + // Name: to.Ptr("ARG_23fa00fd-dda0-4268-b482-2076825cf165_970d8c6d-6b78-4270-92ef-88d5aa2b5f0b_132316363294700000_132316498613900000"), + // Type: to.Ptr("Microsoft.ChangeAnalysis/changes"), + // ID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1"), + // Properties: &armchangeanalysis.ChangeProperties{ + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // InitiatedByList: []*string{ + // to.Ptr("ellen@contoso.com")}, + // PropertyChanges: []*armchangeanalysis.PropertyChange{ + // { + // Description: to.Ptr("The tag of the resource"), + // ChangeCategory: to.Ptr(armchangeanalysis.ChangeCategoryUser), + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // DisplayName: to.Ptr("tags.subscripitonTag"), + // IsDataMasked: to.Ptr(false), + // JSONPath: to.Ptr("tags.subscripitonTag"), + // Level: to.Ptr(armchangeanalysis.LevelImportant), + // NewValue: to.Ptr("new tag value"), + // OldValue: to.Ptr("old tag value"), + // }}, + // ResourceID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1"), + // TimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T02:17:41.39Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("AST_b2ecd7ec-00dd-4d44-bd19-fefc88790c05_da36e22e-f541-44bd-8d89-8f10a27af4ad_132592897881782408_132592957873393845"), + // Type: to.Ptr("Microsoft.ChangeAnalysis/changes"), + // ID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite/extensions/AppStateTracker/providers/Microsoft.ChangeAnalysis/changes/AST_b2ecd7ec-00dd-4d44-bd19-fefc88790c05_da36e22e-f541-44bd-8d89-8f10a27af4ad_132592897881782408_132592957873393845"), + // Properties: &armchangeanalysis.ChangeProperties{ + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // InitiatedByList: []*string{ + // to.Ptr("ellen@contoso.com")}, + // PropertyChanges: []*armchangeanalysis.PropertyChange{ + // { + // Description: to.Ptr("Application setting"), + // ChangeCategory: to.Ptr(armchangeanalysis.ChangeCategoryUser), + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // DisplayName: to.Ptr("APPSETTING_DB_CONNSTR"), + // IsDataMasked: to.Ptr(true), + // JSONPath: to.Ptr("environment.environmentVariables.APPSETTING_DB_CONNSTR"), + // Level: to.Ptr(armchangeanalysis.LevelImportant), + // NewValue: to.Ptr("***New Value Hidden***"), + // OldValue: to.Ptr("***Old Value Hidden***"), + // }}, + // ResourceID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite"), + // TimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T02:17:41.39Z"); return t}()), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/client_factory.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/client_factory.go new file mode 100644 index 000000000000..0f3af3d98c2f --- /dev/null +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/client_factory.go @@ -0,0 +1,54 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchangeanalysis + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourceChangesClient() *ResourceChangesClient { + subClient, _ := NewResourceChangesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewChangesClient() *ChangesClient { + subClient, _ := NewChangesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_constants.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/constants.go similarity index 97% rename from sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_constants.go rename to sdk/resourcemanager/changeanalysis/armchangeanalysis/constants.go index 67ace48bf1eb..c21838924225 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_constants.go +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/constants.go @@ -5,12 +5,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchangeanalysis const ( moduleName = "armchangeanalysis" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ChangeCategory - The change category. diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.mod b/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.mod index 57b3b137463b..5507fa6b7e19 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.mod +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armc go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.sum b/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.sum +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_models.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/models.go similarity index 96% rename from sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_models.go rename to sdk/resourcemanager/changeanalysis/armchangeanalysis/models.go index 99cf5c27c94b..6e05d541fbd2 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_models.go +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchangeanalysis @@ -53,7 +54,7 @@ type ChangeProperties struct { TimeStamp *time.Time `json:"timeStamp,omitempty"` } -// ChangesClientListChangesByResourceGroupOptions contains the optional parameters for the ChangesClient.ListChangesByResourceGroup +// ChangesClientListChangesByResourceGroupOptions contains the optional parameters for the ChangesClient.NewListChangesByResourceGroupPager // method. type ChangesClientListChangesByResourceGroupOptions struct { // A skip token is used to continue retrieving items after an operation returns a partial result. If a previous response contains @@ -62,7 +63,7 @@ type ChangesClientListChangesByResourceGroupOptions struct { SkipToken *string } -// ChangesClientListChangesBySubscriptionOptions contains the optional parameters for the ChangesClient.ListChangesBySubscription +// ChangesClientListChangesBySubscriptionOptions contains the optional parameters for the ChangesClient.NewListChangesBySubscriptionPager // method. type ChangesClientListChangesBySubscriptionOptions struct { // A skip token is used to continue retrieving items after an operation returns a partial result. If a previous response contains @@ -74,7 +75,7 @@ type ChangesClientListChangesBySubscriptionOptions struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -105,7 +106,7 @@ type ErrorResponse struct { Error *ErrorDetail `json:"error,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // A skip token is used to continue retrieving items after an operation returns a partial result. If a previous response contains // a nextLink element, the value of the nextLink element will include a @@ -168,7 +169,7 @@ type Resource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// ResourceChangesClientListOptions contains the optional parameters for the ResourceChangesClient.List method. +// ResourceChangesClientListOptions contains the optional parameters for the ResourceChangesClient.NewListPager method. type ResourceChangesClientListOptions struct { // A skip token is used to continue retrieving items after an operation returns a partial result. If a previous response contains // a nextLink element, the value of the nextLink element will include a diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/models_serde.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/models_serde.go new file mode 100644 index 000000000000..46ed03577ac9 --- /dev/null +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/models_serde.go @@ -0,0 +1,481 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchangeanalysis + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Change. +func (c Change) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Change. +func (c *Change) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChangeList. +func (c ChangeList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChangeList. +func (c *ChangeList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChangeProperties. +func (c ChangeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "changeType", c.ChangeType) + populate(objectMap, "initiatedByList", c.InitiatedByList) + populate(objectMap, "propertyChanges", c.PropertyChanges) + populate(objectMap, "resourceId", c.ResourceID) + populateTimeRFC3339(objectMap, "timeStamp", c.TimeStamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChangeProperties. +func (c *ChangeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "changeType": + err = unpopulate(val, "ChangeType", &c.ChangeType) + delete(rawMsg, key) + case "initiatedByList": + err = unpopulate(val, "InitiatedByList", &c.InitiatedByList) + delete(rawMsg, key) + case "propertyChanges": + err = unpopulate(val, "PropertyChanges", &c.PropertyChanges) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &c.ResourceID) + delete(rawMsg, key) + case "timeStamp": + err = unpopulateTimeRFC3339(val, "TimeStamp", &c.TimeStamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PropertyChange. +func (p PropertyChange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "changeCategory", p.ChangeCategory) + populate(objectMap, "changeType", p.ChangeType) + populate(objectMap, "description", p.Description) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "isDataMasked", p.IsDataMasked) + populate(objectMap, "jsonPath", p.JSONPath) + populate(objectMap, "level", p.Level) + populate(objectMap, "newValue", p.NewValue) + populate(objectMap, "oldValue", p.OldValue) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PropertyChange. +func (p *PropertyChange) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "changeCategory": + err = unpopulate(val, "ChangeCategory", &p.ChangeCategory) + delete(rawMsg, key) + case "changeType": + err = unpopulate(val, "ChangeType", &p.ChangeType) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "isDataMasked": + err = unpopulate(val, "IsDataMasked", &p.IsDataMasked) + delete(rawMsg, key) + case "jsonPath": + err = unpopulate(val, "JSONPath", &p.JSONPath) + delete(rawMsg, key) + case "level": + err = unpopulate(val, "Level", &p.Level) + delete(rawMsg, key) + case "newValue": + err = unpopulate(val, "NewValue", &p.NewValue) + delete(rawMsg, key) + case "oldValue": + err = unpopulate(val, "OldValue", &p.OldValue) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationDefinition. +func (r ResourceProviderOperationDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", r.Display) + populate(objectMap, "name", r.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDefinition. +func (r *ResourceProviderOperationDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &r.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationDisplay. +func (r ResourceProviderOperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", r.Description) + populate(objectMap, "operation", r.Operation) + populate(objectMap, "provider", r.Provider) + populate(objectMap, "resource", r.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDisplay. +func (r *ResourceProviderOperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &r.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &r.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &r.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationList. +func (r ResourceProviderOperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationList. +func (r *ResourceProviderOperationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_operations_client.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/operations_client.go similarity index 78% rename from sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_operations_client.go rename to sdk/resourcemanager/changeanalysis/armchangeanalysis/operations_client.go index e4650f5a6b5a..4c5c96bbba54 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_operations_client.go +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/operations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchangeanalysis @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all the supported operations by the Microsoft.ChangeAnalysis resource provider along with their descriptions. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-04-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.ChangeAnalysis/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/operations_client_example_test.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/operations_client_example_test.go new file mode 100644 index 000000000000..df7791992332 --- /dev/null +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/operations_client_example_test.go @@ -0,0 +1,62 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchangeanalysis_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armchangeanalysis" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/OperationsList.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchangeanalysis.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(&armchangeanalysis.OperationsClientListOptions{SkipToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ResourceProviderOperationList = armchangeanalysis.ResourceProviderOperationList{ + // Value: []*armchangeanalysis.ResourceProviderOperationDefinition{ + // { + // Name: to.Ptr("Microsoft.ChangeAnalysis/register/action"), + // Display: &armchangeanalysis.ResourceProviderOperationDisplay{ + // Operation: to.Ptr("Register Microsoft Change Analysis resource provider with a subscriptions"), + // Provider: to.Ptr("Microsoft Change Analysis"), + // Resource: to.Ptr(""), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.ChangeAnalysis/changes/read"), + // Display: &armchangeanalysis.ResourceProviderOperationDisplay{ + // Operation: to.Ptr("Read Azure Application Change Analysis Servie Change"), + // Provider: to.Ptr("Microsoft Change Analysis"), + // Resource: to.Ptr("Azure Application Change Analysis Service Change"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_resourcechanges_client.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/resourcechanges_client.go similarity index 78% rename from sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_resourcechanges_client.go rename to sdk/resourcemanager/changeanalysis/armchangeanalysis/resourcechanges_client.go index 0ba01d67e3b0..be968f6818df 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_resourcechanges_client.go +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/resourcechanges_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchangeanalysis @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,40 +25,32 @@ import ( // ResourceChangesClient contains the methods for the ResourceChanges group. // Don't use this type directly, use NewResourceChangesClient() instead. type ResourceChangesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewResourceChangesClient creates a new instance of ResourceChangesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewResourceChangesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceChangesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ResourceChangesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourceChangesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List the changes of a resource within the specified time range. Customer data will be masked if the user // doesn't have access. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-04-01 -// resourceID - The identifier of the resource. -// startTime - Specifies the start time of the changes request. -// endTime - Specifies the end time of the changes request. -// options - ResourceChangesClientListOptions contains the optional parameters for the ResourceChangesClient.List method. +// - resourceID - The identifier of the resource. +// - startTime - Specifies the start time of the changes request. +// - endTime - Specifies the end time of the changes request. +// - options - ResourceChangesClientListOptions contains the optional parameters for the ResourceChangesClient.NewListPager +// method. func (client *ResourceChangesClient) NewListPager(resourceID string, startTime time.Time, endTime time.Time, options *ResourceChangesClientListOptions) *runtime.Pager[ResourceChangesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourceChangesClientListResponse]{ More: func(page ResourceChangesClientListResponse) bool { @@ -76,7 +67,7 @@ func (client *ResourceChangesClient) NewListPager(resourceID string, startTime t if err != nil { return ResourceChangesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceChangesClientListResponse{}, err } @@ -95,7 +86,7 @@ func (client *ResourceChangesClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter resourceID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceId}", url.PathEscape(resourceID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/resourcechanges_client_example_test.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/resourcechanges_client_example_test.go new file mode 100644 index 000000000000..bb376e4c9ade --- /dev/null +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/resourcechanges_client_example_test.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchangeanalysis_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armchangeanalysis" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ResourceChangesList.json +func ExampleResourceChangesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchangeanalysis.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewResourceChangesClient().NewListPager("subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite", func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-25T12:09:03.141Z"); return t }(), func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T12:09:03.141Z"); return t }(), &armchangeanalysis.ResourceChangesClientListOptions{SkipToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ChangeList = armchangeanalysis.ChangeList{ + // Value: []*armchangeanalysis.Change{ + // { + // Name: to.Ptr("ARG_23fa00fd-dda0-4268-b482-2076825cf165_970d8c6d-6b78-4270-92ef-88d5aa2b5f0b_132316363294700000_132316498613900000"), + // Type: to.Ptr("Microsoft.ChangeAnalysis/resourceChanges"), + // ID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite/providers/Microsoft.ChangeAnalysis/resourceChanges/ARG_23fa00fd-dda0-4268-b482-2076825cf165_970d8c6d-6b78-4270-92ef-88d5aa2b5f0b_132316363294700000_132316498613900000"), + // Properties: &armchangeanalysis.ChangeProperties{ + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // InitiatedByList: []*string{ + // to.Ptr("ellen@contoso.com")}, + // PropertyChanges: []*armchangeanalysis.PropertyChange{ + // { + // Description: to.Ptr("The thumbprint of the certificate"), + // ChangeCategory: to.Ptr(armchangeanalysis.ChangeCategoryUser), + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // DisplayName: to.Ptr("publicCertificates[\"AppCert\"].properties.thumbprint"), + // IsDataMasked: to.Ptr(false), + // JSONPath: to.Ptr("value[1].properties.thumbprint"), + // Level: to.Ptr(armchangeanalysis.LevelImportant), + // NewValue: to.Ptr("3F2DF554-B063-4383-8BD3-4970BCF20A7E"), + // OldValue: to.Ptr("21D0482F-E91E-4C14-8078-65BFDCDBCA64"), + // }}, + // ResourceID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite"), + // TimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T02:17:41.39Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("AST_b2ecd7ec-00dd-4d44-bd19-fefc88790c05_da36e22e-f541-44bd-8d89-8f10a27af4ad_132592897881782408_132592957873393845"), + // Type: to.Ptr("Microsoft.ChangeAnalysis/changes"), + // ID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite/extensions/AppStateTracker/providers/Microsoft.ChangeAnalysis/resourceChanges/AST_b2ecd7ec-00dd-4d44-bd19-fefc88790c05_da36e22e-f541-44bd-8d89-8f10a27af4ad_132592897881782408_132592957873393845"), + // Properties: &armchangeanalysis.ChangeProperties{ + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // InitiatedByList: []*string{ + // to.Ptr("ellen@contoso.com")}, + // PropertyChanges: []*armchangeanalysis.PropertyChange{ + // { + // Description: to.Ptr("Application setting"), + // ChangeCategory: to.Ptr(armchangeanalysis.ChangeCategoryUser), + // ChangeType: to.Ptr(armchangeanalysis.ChangeTypeUpdate), + // DisplayName: to.Ptr("APPSETTING_DB_CONNSTR"), + // IsDataMasked: to.Ptr(false), + // JSONPath: to.Ptr("environment.environmentVariables.APPSETTING_DB_CONNSTR"), + // Level: to.Ptr(armchangeanalysis.LevelImportant), + // NewValue: to.Ptr(""), + // OldValue: to.Ptr(""), + // }}, + // ResourceID: to.Ptr("/subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite"), + // TimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T02:17:41.39Z"); return t}()), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_response_types.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/response_types.go similarity index 79% rename from sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_response_types.go rename to sdk/resourcemanager/changeanalysis/armchangeanalysis/response_types.go index cb3cf965f5cb..eaa90922e258 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_response_types.go +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/response_types.go @@ -5,25 +5,26 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchangeanalysis -// ChangesClientListChangesByResourceGroupResponse contains the response from method ChangesClient.ListChangesByResourceGroup. +// ChangesClientListChangesByResourceGroupResponse contains the response from method ChangesClient.NewListChangesByResourceGroupPager. type ChangesClientListChangesByResourceGroupResponse struct { ChangeList } -// ChangesClientListChangesBySubscriptionResponse contains the response from method ChangesClient.ListChangesBySubscription. +// ChangesClientListChangesBySubscriptionResponse contains the response from method ChangesClient.NewListChangesBySubscriptionPager. type ChangesClientListChangesBySubscriptionResponse struct { ChangeList } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { ResourceProviderOperationList } -// ResourceChangesClientListResponse contains the response from method ResourceChangesClient.List. +// ResourceChangesClientListResponse contains the response from method ResourceChangesClient.NewListPager. type ResourceChangesClientListResponse struct { ChangeList } diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_time_rfc3339.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/changeanalysis/armchangeanalysis/time_rfc3339.go index 8c262cb966be..5b5cfeba97a3 100644 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/changeanalysis/armchangeanalysis/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchangeanalysis @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_changes_client_test.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_changes_client_test.go deleted file mode 100644 index a1f297be68e6..000000000000 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_changes_client_test.go +++ /dev/null @@ -1,72 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchangeanalysis_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armchangeanalysis" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ChangesListChangesByResourceGroup.json -func ExampleChangesClient_NewListChangesByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchangeanalysis.NewChangesClient("4d962866-1e3f-47f2-bd18-450c08f914c1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListChangesByResourceGroupPager("MyResourceGroup", - func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-25T12:09:03.141Z"); return t }(), - func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T12:09:03.141Z"); return t }(), - &armchangeanalysis.ChangesClientListChangesByResourceGroupOptions{SkipToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ChangesListChangesBySubscription.json -func ExampleChangesClient_NewListChangesBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchangeanalysis.NewChangesClient("4d962866-1e3f-47f2-bd18-450c08f914c1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListChangesBySubscriptionPager(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-25T12:09:03.141Z"); return t }(), - func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T12:09:03.141Z"); return t }(), - &armchangeanalysis.ChangesClientListChangesBySubscriptionOptions{SkipToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_operations_client_test.go deleted file mode 100644 index dacce26e545f..000000000000 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchangeanalysis_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armchangeanalysis" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/OperationsList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchangeanalysis.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armchangeanalysis.OperationsClientListOptions{SkipToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_resourcechanges_client_test.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_resourcechanges_client_test.go deleted file mode 100644 index 866f1e2537ce..000000000000 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/ze_generated_example_resourcechanges_client_test.go +++ /dev/null @@ -1,46 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchangeanalysis_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/changeanalysis/armchangeanalysis" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ResourceChangesList.json -func ExampleResourceChangesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchangeanalysis.NewResourceChangesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite", - func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-25T12:09:03.141Z"); return t }(), - func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-26T12:09:03.141Z"); return t }(), - &armchangeanalysis.ResourceChangesClientListOptions{SkipToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_models_serde.go b/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_models_serde.go deleted file mode 100644 index 1bcb51c5bcd5..000000000000 --- a/sdk/resourcemanager/changeanalysis/armchangeanalysis/zz_generated_models_serde.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchangeanalysis - -import ( - "encoding/json" - "fmt" -) - -// UnmarshalJSON implements the json.Unmarshaller interface for type ChangeProperties. -func (c *ChangeProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "changeType": - err = unpopulate(val, "ChangeType", &c.ChangeType) - delete(rawMsg, key) - case "initiatedByList": - err = unpopulate(val, "InitiatedByList", &c.InitiatedByList) - delete(rawMsg, key) - case "propertyChanges": - err = unpopulate(val, "PropertyChanges", &c.PropertyChanges) - delete(rawMsg, key) - case "resourceId": - err = unpopulate(val, "ResourceID", &c.ResourceID) - delete(rawMsg, key) - case "timeStamp": - err = unpopulateTimeRFC3339(val, "TimeStamp", &c.TimeStamp) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md index f64cb2f70f6a..fe5e0fe4ba82 100644 --- a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md +++ b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.5.0, which contains breaking changes. diff --git a/sdk/resourcemanager/chaos/armchaos/README.md b/sdk/resourcemanager/chaos/armchaos/README.md index 8ae1ff792288..84720da1c895 100644 --- a/sdk/resourcemanager/chaos/armchaos/README.md +++ b/sdk/resourcemanager/chaos/armchaos/README.md @@ -34,12 +34,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Chaos modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Chaos module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armchaos.NewExperimentsClient(, cred, nil) +clientFactory, err := armchaos.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -50,7 +50,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armchaos.NewExperimentsClient(, cred, &options) +clientFactory, err := armchaos.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewTargetsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/chaos/armchaos/autorest.md b/sdk/resourcemanager/chaos/armchaos/autorest.md index 3e4d42f635dd..6f8e67488a1e 100644 --- a/sdk/resourcemanager/chaos/armchaos/autorest.md +++ b/sdk/resourcemanager/chaos/armchaos/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go b/sdk/resourcemanager/chaos/armchaos/capabilities_client.go similarity index 83% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go rename to sdk/resourcemanager/chaos/armchaos/capabilities_client.go index c6fc29372416..568e1e5af459 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilities_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,53 +24,45 @@ import ( // CapabilitiesClient contains the methods for the Capabilities group. // Don't use this type directly, use NewCapabilitiesClient() instead. type CapabilitiesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCapabilitiesClient creates a new instance of CapabilitiesClient with the specified values. -// subscriptionID - GUID that represents an Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - GUID that represents an Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCapabilitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CapabilitiesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CapabilitiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CapabilitiesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update a Capability resource that extends a Target resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// targetName - String that represents a Target resource name. -// capabilityName - String that represents a Capability resource name. -// capability - Capability resource to be created or updated. -// options - CapabilitiesClientCreateOrUpdateOptions contains the optional parameters for the CapabilitiesClient.CreateOrUpdate -// method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - targetName - String that represents a Target resource name. +// - capabilityName - String that represents a Capability resource name. +// - capability - Capability resource to be created or updated. +// - options - CapabilitiesClientCreateOrUpdateOptions contains the optional parameters for the CapabilitiesClient.CreateOrUpdate +// method. func (client *CapabilitiesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, capability Capability, options *CapabilitiesClientCreateOrUpdateOptions) (CapabilitiesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, capability, options) if err != nil { return CapabilitiesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CapabilitiesClientCreateOrUpdateResponse{}, err } @@ -112,7 +103,7 @@ func (client *CapabilitiesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter capabilityName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{capabilityName}", url.PathEscape(capabilityName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -134,20 +125,21 @@ func (client *CapabilitiesClient) createOrUpdateHandleResponse(resp *http.Respon // Delete - Delete a Capability that extends a Target resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// targetName - String that represents a Target resource name. -// capabilityName - String that represents a Capability resource name. -// options - CapabilitiesClientDeleteOptions contains the optional parameters for the CapabilitiesClient.Delete method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - targetName - String that represents a Target resource name. +// - capabilityName - String that represents a Capability resource name. +// - options - CapabilitiesClientDeleteOptions contains the optional parameters for the CapabilitiesClient.Delete method. func (client *CapabilitiesClient) Delete(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesClientDeleteOptions) (CapabilitiesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) if err != nil { return CapabilitiesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CapabilitiesClientDeleteResponse{}, err } @@ -188,7 +180,7 @@ func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter capabilityName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{capabilityName}", url.PathEscape(capabilityName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -201,20 +193,21 @@ func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resou // Get - Get a Capability resource that extends a Target resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// targetName - String that represents a Target resource name. -// capabilityName - String that represents a Capability resource name. -// options - CapabilitiesClientGetOptions contains the optional parameters for the CapabilitiesClient.Get method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - targetName - String that represents a Target resource name. +// - capabilityName - String that represents a Capability resource name. +// - options - CapabilitiesClientGetOptions contains the optional parameters for the CapabilitiesClient.Get method. func (client *CapabilitiesClient) Get(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesClientGetOptions) (CapabilitiesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) if err != nil { return CapabilitiesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CapabilitiesClientGetResponse{}, err } @@ -255,7 +248,7 @@ func (client *CapabilitiesClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter capabilityName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{capabilityName}", url.PathEscape(capabilityName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -276,14 +269,14 @@ func (client *CapabilitiesClient) getHandleResponse(resp *http.Response) (Capabi } // NewListPager - Get a list of Capability resources that extend a Target resource.. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// targetName - String that represents a Target resource name. -// options - CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.List method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - targetName - String that represents a Target resource name. +// - options - CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.NewListPager method. func (client *CapabilitiesClient) NewListPager(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *CapabilitiesClientListOptions) *runtime.Pager[CapabilitiesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CapabilitiesClientListResponse]{ More: func(page CapabilitiesClientListResponse) bool { @@ -300,7 +293,7 @@ func (client *CapabilitiesClient) NewListPager(resourceGroupName string, parentP if err != nil { return CapabilitiesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CapabilitiesClientListResponse{}, err } @@ -339,7 +332,7 @@ func (client *CapabilitiesClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter targetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/chaos/armchaos/capabilities_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/capabilities_client_example_test.go new file mode 100644 index 000000000000..454befe03471 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/capabilities_client_example_test.go @@ -0,0 +1,153 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListCapabilities.json +func ExampleCapabilitiesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCapabilitiesClient().NewListPager("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", &armchaos.CapabilitiesClientListOptions{ContinuationToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CapabilityListResult = armchaos.CapabilityListResult{ + // Value: []*armchaos.Capability{ + // { + // Name: to.Ptr("Shutdown-1.0"), + // Type: to.Ptr("Microsoft.Chaos/targets/capabilities"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0"), + // Properties: &armchaos.CapabilityProperties{ + // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), + // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), + // Publisher: to.Ptr("Microsoft"), + // TargetType: to.Ptr("VirtualMachine"), + // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.4662189Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.4662189Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapability.json +func ExampleCapabilitiesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCapabilitiesClient().Get(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", "Shutdown-1.0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Capability = armchaos.Capability{ + // Name: to.Ptr("Shutdown-1.0"), + // Type: to.Ptr("Microsoft.Chaos/targets/capabilities"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0"), + // Properties: &armchaos.CapabilityProperties{ + // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), + // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), + // Publisher: to.Ptr("Microsoft"), + // TargetType: to.Ptr("VirtualMachine"), + // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.4662189Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.4662189Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteACapability.json +func ExampleCapabilitiesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewCapabilitiesClient().Delete(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", "Shutdown-1.0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateACapability.json +func ExampleCapabilitiesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCapabilitiesClient().CreateOrUpdate(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", "Shutdown-1.0", armchaos.Capability{ + Properties: &armchaos.CapabilityProperties{}, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Capability = armchaos.Capability{ + // Name: to.Ptr("Shutdown-1.0"), + // Type: to.Ptr("Microsoft.Chaos/targets/capabilities"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0"), + // Properties: &armchaos.CapabilityProperties{ + // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), + // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), + // Publisher: to.Ptr("Microsoft"), + // TargetType: to.Ptr("VirtualMachine"), + // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.4662189Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.4662189Z"); return t}()), + // }, + // } +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go similarity index 81% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go rename to sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go index cbfe07c6cfe8..6ff14f117693 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // CapabilityTypesClient contains the methods for the CapabilityTypes group. // Don't use this type directly, use NewCapabilityTypesClient() instead. type CapabilityTypesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCapabilityTypesClient creates a new instance of CapabilityTypesClient with the specified values. -// subscriptionID - GUID that represents an Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - GUID that represents an Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCapabilityTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CapabilityTypesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CapabilityTypesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CapabilityTypesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get a Capability Type resource for given Target Type and location. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// locationName - String that represents a Location resource name. -// targetTypeName - String that represents a Target Type resource name. -// capabilityTypeName - String that represents a Capability Type resource name. -// options - CapabilityTypesClientGetOptions contains the optional parameters for the CapabilityTypesClient.Get method. +// - locationName - String that represents a Location resource name. +// - targetTypeName - String that represents a Target Type resource name. +// - capabilityTypeName - String that represents a Capability Type resource name. +// - options - CapabilityTypesClientGetOptions contains the optional parameters for the CapabilityTypesClient.Get method. func (client *CapabilityTypesClient) Get(ctx context.Context, locationName string, targetTypeName string, capabilityTypeName string, options *CapabilityTypesClientGetOptions) (CapabilityTypesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, locationName, targetTypeName, capabilityTypeName, options) if err != nil { return CapabilityTypesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CapabilityTypesClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *CapabilityTypesClient) getCreateRequest(ctx context.Context, locat return nil, errors.New("parameter capabilityTypeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{capabilityTypeName}", url.PathEscape(capabilityTypeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,12 @@ func (client *CapabilityTypesClient) getHandleResponse(resp *http.Response) (Cap } // NewListPager - Get a list of Capability Type resources for given Target Type and location. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// locationName - String that represents a Location resource name. -// targetTypeName - String that represents a Target Type resource name. -// options - CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.List method. +// - locationName - String that represents a Location resource name. +// - targetTypeName - String that represents a Target Type resource name. +// - options - CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.NewListPager +// method. func (client *CapabilityTypesClient) NewListPager(locationName string, targetTypeName string, options *CapabilityTypesClientListOptions) *runtime.Pager[CapabilityTypesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CapabilityTypesClientListResponse]{ More: func(page CapabilityTypesClientListResponse) bool { @@ -137,7 +129,7 @@ func (client *CapabilityTypesClient) NewListPager(locationName string, targetTyp if err != nil { return CapabilityTypesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CapabilityTypesClientListResponse{}, err } @@ -164,7 +156,7 @@ func (client *CapabilityTypesClient) listCreateRequest(ctx context.Context, loca return nil, errors.New("parameter targetTypeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{targetTypeName}", url.PathEscape(targetTypeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client_example_test.go new file mode 100644 index 000000000000..85475e8bb267 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client_example_test.go @@ -0,0 +1,92 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListCapabilityTypes.json +func ExampleCapabilityTypesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCapabilityTypesClient().NewListPager("westus2", "Microsoft-VirtualMachine", &armchaos.CapabilityTypesClientListOptions{ContinuationToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CapabilityTypeListResult = armchaos.CapabilityTypeListResult{ + // Value: []*armchaos.CapabilityType{ + // { + // Name: to.Ptr("Shutdown-1.0"), + // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes/capabilityTypes"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/providers/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-VirtualMachine/capabilityTypes/Shutdown-1.0"), + // Properties: &armchaos.CapabilityTypeProperties{ + // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), + // DisplayName: to.Ptr("Shutdown VM"), + // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), + // Publisher: to.Ptr("Microsoft"), + // TargetType: to.Ptr("VirtualMachine"), + // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapabilityType.json +func ExampleCapabilityTypesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCapabilityTypesClient().Get(ctx, "westus2", "Microsoft-VirtualMachine", "Shutdown-1.0", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CapabilityType = armchaos.CapabilityType{ + // Name: to.Ptr("Shutdown-1.0"), + // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes/capabilityTypes"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-VirtualMachine/capabilityTypes/Shutdown-1.0"), + // Properties: &armchaos.CapabilityTypeProperties{ + // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), + // DisplayName: to.Ptr("Shutdown VM"), + // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), + // Publisher: to.Ptr("Microsoft"), + // TargetType: to.Ptr("VirtualMachine"), + // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), + // }, + // } +} diff --git a/sdk/resourcemanager/chaos/armchaos/client_factory.go b/sdk/resourcemanager/chaos/armchaos/client_factory.go new file mode 100644 index 000000000000..7cb8b5ed1441 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/client_factory.go @@ -0,0 +1,69 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchaos + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - GUID that represents an Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewCapabilitiesClient() *CapabilitiesClient { + subClient, _ := NewCapabilitiesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewExperimentsClient() *ExperimentsClient { + subClient, _ := NewExperimentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTargetsClient() *TargetsClient { + subClient, _ := NewTargetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTargetTypesClient() *TargetTypesClient { + subClient, _ := NewTargetTypesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCapabilityTypesClient() *CapabilityTypesClient { + subClient, _ := NewCapabilityTypesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go b/sdk/resourcemanager/chaos/armchaos/constants.go similarity index 98% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go rename to sdk/resourcemanager/chaos/armchaos/constants.go index 1a1b5fec5363..8188d10cfcec 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go +++ b/sdk/resourcemanager/chaos/armchaos/constants.go @@ -5,12 +5,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos const ( moduleName = "armchaos" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go b/sdk/resourcemanager/chaos/armchaos/experiments_client.go similarity index 86% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go rename to sdk/resourcemanager/chaos/armchaos/experiments_client.go index e6f6877213d6..9b1f7fccb8a6 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go +++ b/sdk/resourcemanager/chaos/armchaos/experiments_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,64 +25,57 @@ import ( // ExperimentsClient contains the methods for the Experiments group. // Don't use this type directly, use NewExperimentsClient() instead. type ExperimentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewExperimentsClient creates a new instance of ExperimentsClient with the specified values. -// subscriptionID - GUID that represents an Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - GUID that represents an Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewExperimentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExperimentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ExperimentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ExperimentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCancel - Cancel a running Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientBeginCancelOptions contains the optional parameters for the ExperimentsClient.BeginCancel method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientBeginCancelOptions contains the optional parameters for the ExperimentsClient.BeginCancel method. func (client *ExperimentsClient) BeginCancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginCancelOptions) (*runtime.Poller[ExperimentsClientCancelResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.cancel(ctx, resourceGroupName, experimentName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ExperimentsClientCancelResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExperimentsClientCancelResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, }) } else { - return runtime.NewPollerFromResumeToken[ExperimentsClientCancelResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ExperimentsClientCancelResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Cancel - Cancel a running Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview func (client *ExperimentsClient) cancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginCancelOptions) (*http.Response, error) { req, err := client.cancelCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -108,7 +100,7 @@ func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resour return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,35 +113,37 @@ func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resour // BeginCreateOrUpdate - Create or update a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// experiment - Experiment resource to be created or updated. -// options - ExperimentsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - experiment - Experiment resource to be created or updated. +// - options - ExperimentsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.BeginCreateOrUpdate +// method. func (client *ExperimentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExperimentsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, experimentName, experiment, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ExperimentsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExperimentsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, }) } else { - return runtime.NewPollerFromResumeToken[ExperimentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ExperimentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or update a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview func (client *ExperimentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, experimentName, experiment, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -174,7 +168,7 @@ func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -187,16 +181,17 @@ func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context // Delete - Delete a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientDeleteOptions contains the optional parameters for the ExperimentsClient.Delete method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientDeleteOptions contains the optional parameters for the ExperimentsClient.Delete method. func (client *ExperimentsClient) Delete(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientDeleteOptions) (ExperimentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { return ExperimentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientDeleteResponse{}, err } @@ -221,7 +216,7 @@ func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,16 +229,17 @@ func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Get a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientGetOptions contains the optional parameters for the ExperimentsClient.Get method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientGetOptions contains the optional parameters for the ExperimentsClient.Get method. func (client *ExperimentsClient) Get(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientGetOptions) (ExperimentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { return ExperimentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientGetResponse{}, err } @@ -268,7 +264,7 @@ func (client *ExperimentsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -290,18 +286,19 @@ func (client *ExperimentsClient) getHandleResponse(resp *http.Response) (Experim // GetExecutionDetails - Get an execution detail of a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// executionDetailsID - GUID that represents a Experiment execution detail. -// options - ExperimentsClientGetExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.GetExecutionDetails -// method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - executionDetailsID - GUID that represents a Experiment execution detail. +// - options - ExperimentsClientGetExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.GetExecutionDetails +// method. func (client *ExperimentsClient) GetExecutionDetails(ctx context.Context, resourceGroupName string, experimentName string, executionDetailsID string, options *ExperimentsClientGetExecutionDetailsOptions) (ExperimentsClientGetExecutionDetailsResponse, error) { req, err := client.getExecutionDetailsCreateRequest(ctx, resourceGroupName, experimentName, executionDetailsID, options) if err != nil { return ExperimentsClientGetExecutionDetailsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientGetExecutionDetailsResponse{}, err } @@ -330,7 +327,7 @@ func (client *ExperimentsClient) getExecutionDetailsCreateRequest(ctx context.Co return nil, errors.New("parameter executionDetailsID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{executionDetailsId}", url.PathEscape(executionDetailsID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -352,17 +349,18 @@ func (client *ExperimentsClient) getExecutionDetailsHandleResponse(resp *http.Re // GetStatus - Get a status of a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// statusID - GUID that represents a Experiment status. -// options - ExperimentsClientGetStatusOptions contains the optional parameters for the ExperimentsClient.GetStatus method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - statusID - GUID that represents a Experiment status. +// - options - ExperimentsClientGetStatusOptions contains the optional parameters for the ExperimentsClient.GetStatus method. func (client *ExperimentsClient) GetStatus(ctx context.Context, resourceGroupName string, experimentName string, statusID string, options *ExperimentsClientGetStatusOptions) (ExperimentsClientGetStatusResponse, error) { req, err := client.getStatusCreateRequest(ctx, resourceGroupName, experimentName, statusID, options) if err != nil { return ExperimentsClientGetStatusResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientGetStatusResponse{}, err } @@ -391,7 +389,7 @@ func (client *ExperimentsClient) getStatusCreateRequest(ctx context.Context, res return nil, errors.New("parameter statusID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{statusId}", url.PathEscape(statusID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -412,10 +410,10 @@ func (client *ExperimentsClient) getStatusHandleResponse(resp *http.Response) (E } // NewListPager - Get a list of Experiment resources in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// options - ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.List method. +// - resourceGroupName - String that represents an Azure resource group. +// - options - ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.NewListPager method. func (client *ExperimentsClient) NewListPager(resourceGroupName string, options *ExperimentsClientListOptions) *runtime.Pager[ExperimentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListResponse]{ More: func(page ExperimentsClientListResponse) bool { @@ -432,7 +430,7 @@ func (client *ExperimentsClient) NewListPager(resourceGroupName string, options if err != nil { return ExperimentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientListResponse{}, err } @@ -455,7 +453,7 @@ func (client *ExperimentsClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -482,9 +480,9 @@ func (client *ExperimentsClient) listHandleResponse(resp *http.Response) (Experi } // NewListAllPager - Get a list of Experiment resources in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// options - ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.ListAll method. +// - options - ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.NewListAllPager method. func (client *ExperimentsClient) NewListAllPager(options *ExperimentsClientListAllOptions) *runtime.Pager[ExperimentsClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListAllResponse]{ More: func(page ExperimentsClientListAllResponse) bool { @@ -501,7 +499,7 @@ func (client *ExperimentsClient) NewListAllPager(options *ExperimentsClientListA if err != nil { return ExperimentsClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientListAllResponse{}, err } @@ -520,7 +518,7 @@ func (client *ExperimentsClient) listAllCreateRequest(ctx context.Context, optio return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -547,12 +545,12 @@ func (client *ExperimentsClient) listAllHandleResponse(resp *http.Response) (Exp } // NewListAllStatusesPager - Get a list of statuses of a Experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.ListAllStatuses -// method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.NewListAllStatusesPager +// method. func (client *ExperimentsClient) NewListAllStatusesPager(resourceGroupName string, experimentName string, options *ExperimentsClientListAllStatusesOptions) *runtime.Pager[ExperimentsClientListAllStatusesResponse] { return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListAllStatusesResponse]{ More: func(page ExperimentsClientListAllStatusesResponse) bool { @@ -569,7 +567,7 @@ func (client *ExperimentsClient) NewListAllStatusesPager(resourceGroupName strin if err != nil { return ExperimentsClientListAllStatusesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientListAllStatusesResponse{}, err } @@ -596,7 +594,7 @@ func (client *ExperimentsClient) listAllStatusesCreateRequest(ctx context.Contex return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -617,12 +615,12 @@ func (client *ExperimentsClient) listAllStatusesHandleResponse(resp *http.Respon } // NewListExecutionDetailsPager - Get a list of execution details of a Experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.ListExecutionDetails -// method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.NewListExecutionDetailsPager +// method. func (client *ExperimentsClient) NewListExecutionDetailsPager(resourceGroupName string, experimentName string, options *ExperimentsClientListExecutionDetailsOptions) *runtime.Pager[ExperimentsClientListExecutionDetailsResponse] { return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListExecutionDetailsResponse]{ More: func(page ExperimentsClientListExecutionDetailsResponse) bool { @@ -639,7 +637,7 @@ func (client *ExperimentsClient) NewListExecutionDetailsPager(resourceGroupName if err != nil { return ExperimentsClientListExecutionDetailsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientListExecutionDetailsResponse{}, err } @@ -666,7 +664,7 @@ func (client *ExperimentsClient) listExecutionDetailsCreateRequest(ctx context.C return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -688,16 +686,17 @@ func (client *ExperimentsClient) listExecutionDetailsHandleResponse(resp *http.R // Start - Start a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientStartOptions contains the optional parameters for the ExperimentsClient.Start method. +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientStartOptions contains the optional parameters for the ExperimentsClient.Start method. func (client *ExperimentsClient) Start(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientStartOptions) (ExperimentsClientStartResponse, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { return ExperimentsClientStartResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientStartResponse{}, err } @@ -722,7 +721,7 @@ func (client *ExperimentsClient) startCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/chaos/armchaos/experiments_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/experiments_client_example_test.go new file mode 100644 index 000000000000..4a298fb0c5d4 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/experiments_client_example_test.go @@ -0,0 +1,591 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentsInASubscription.json +func ExampleExperimentsClient_NewListAllPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewExperimentsClient().NewListAllPager(&armchaos.ExperimentsClientListAllOptions{Running: nil, + ContinuationToken: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ExperimentListResult = armchaos.ExperimentListResult{ + // Value: []*armchaos.Experiment{ + // { + // Name: to.Ptr("exampleExperiment"), + // Type: to.Ptr("Microsoft.Chaos/experiments"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), + // Location: to.Ptr("centraluseuap"), + // Identity: &armchaos.ResourceIdentity{ + // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), + // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), + // }, + // Properties: &armchaos.ExperimentProperties{ + // Selectors: []*armchaos.Selector{ + // { + // Type: to.Ptr(armchaos.SelectorTypeList), + // ID: to.Ptr("selector1"), + // Targets: []*armchaos.TargetReference{ + // { + // Type: to.Ptr("ChaosTarget"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), + // }}, + // }}, + // Steps: []*armchaos.Step{ + // { + // Name: to.Ptr("step1"), + // Branches: []*armchaos.Branch{ + // { + // Name: to.Ptr("branch1"), + // Actions: []armchaos.ActionClassification{ + // &armchaos.Action{ + // Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), + // Type: to.Ptr("Continuous"), + // }}, + // }}, + // }}, + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // CreatedBy: to.Ptr("User"), + // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // LastModifiedBy: to.Ptr("User"), + // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentsInAResourceGroup.json +func ExampleExperimentsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewExperimentsClient().NewListPager("exampleRG", &armchaos.ExperimentsClientListOptions{Running: nil, + ContinuationToken: nil, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ExperimentListResult = armchaos.ExperimentListResult{ + // Value: []*armchaos.Experiment{ + // { + // Name: to.Ptr("exampleExperiment"), + // Type: to.Ptr("Microsoft.Chaos/experiments"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), + // Location: to.Ptr("centraluseuap"), + // Identity: &armchaos.ResourceIdentity{ + // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), + // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), + // }, + // Properties: &armchaos.ExperimentProperties{ + // Selectors: []*armchaos.Selector{ + // { + // Type: to.Ptr(armchaos.SelectorTypeList), + // ID: to.Ptr("selector1"), + // Targets: []*armchaos.TargetReference{ + // { + // Type: to.Ptr("ChaosTarget"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), + // }}, + // }}, + // Steps: []*armchaos.Step{ + // { + // Name: to.Ptr("step1"), + // Branches: []*armchaos.Branch{ + // { + // Name: to.Ptr("branch1"), + // Actions: []armchaos.ActionClassification{ + // &armchaos.Action{ + // Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), + // Type: to.Ptr("Continuous"), + // }}, + // }}, + // }}, + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // CreatedBy: to.Ptr("User"), + // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // LastModifiedBy: to.Ptr("User"), + // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteAExperiment.json +func ExampleExperimentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewExperimentsClient().Delete(ctx, "exampleRG", "exampleExperiment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperiment.json +func ExampleExperimentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExperimentsClient().Get(ctx, "exampleRG", "exampleExperiment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Experiment = armchaos.Experiment{ + // Name: to.Ptr("exampleExperiment"), + // Type: to.Ptr("Microsoft.Chaos/experiments"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), + // Location: to.Ptr("centraluseuap"), + // Identity: &armchaos.ResourceIdentity{ + // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), + // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), + // }, + // Properties: &armchaos.ExperimentProperties{ + // Selectors: []*armchaos.Selector{ + // { + // Type: to.Ptr(armchaos.SelectorTypeList), + // ID: to.Ptr("selector1"), + // Targets: []*armchaos.TargetReference{ + // { + // Type: to.Ptr("ChaosTarget"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), + // }}, + // }}, + // Steps: []*armchaos.Step{ + // { + // Name: to.Ptr("step1"), + // Branches: []*armchaos.Branch{ + // { + // Name: to.Ptr("branch1"), + // Actions: []armchaos.ActionClassification{ + // &armchaos.Action{ + // Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), + // Type: to.Ptr("Continuous"), + // }}, + // }}, + // }}, + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // CreatedBy: to.Ptr("User"), + // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // LastModifiedBy: to.Ptr("User"), + // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateAExperiment.json +func ExampleExperimentsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewExperimentsClient().BeginCreateOrUpdate(ctx, "exampleRG", "exampleExperiment", armchaos.Experiment{ + Location: to.Ptr("centraluseuap"), + Identity: &armchaos.ResourceIdentity{ + Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), + }, + Properties: &armchaos.ExperimentProperties{ + Selectors: []*armchaos.Selector{ + { + Type: to.Ptr(armchaos.SelectorTypeList), + ID: to.Ptr("selector1"), + Targets: []*armchaos.TargetReference{ + { + Type: to.Ptr("ChaosTarget"), + ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), + }}, + }}, + Steps: []*armchaos.Step{ + { + Name: to.Ptr("step1"), + Branches: []*armchaos.Branch{ + { + Name: to.Ptr("branch1"), + Actions: []armchaos.ActionClassification{ + &armchaos.Action{ + Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), + Type: to.Ptr("Continuous"), + }}, + }}, + }}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Experiment = armchaos.Experiment{ + // Name: to.Ptr("exampleExperiment"), + // Type: to.Ptr("Microsoft.Chaos/experiments"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), + // Location: to.Ptr("centraluseuap"), + // Identity: &armchaos.ResourceIdentity{ + // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), + // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), + // }, + // Properties: &armchaos.ExperimentProperties{ + // Selectors: []*armchaos.Selector{ + // { + // Type: to.Ptr(armchaos.SelectorTypeList), + // ID: to.Ptr("selector1"), + // Targets: []*armchaos.TargetReference{ + // { + // Type: to.Ptr("ChaosTarget"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), + // }}, + // }}, + // Steps: []*armchaos.Step{ + // { + // Name: to.Ptr("step1"), + // Branches: []*armchaos.Branch{ + // { + // Name: to.Ptr("branch1"), + // Actions: []armchaos.ActionClassification{ + // &armchaos.Action{ + // Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), + // Type: to.Ptr("Continuous"), + // }}, + // }}, + // }}, + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // CreatedBy: to.Ptr("User"), + // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // LastModifiedBy: to.Ptr("User"), + // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CancelAExperiment.json +func ExampleExperimentsClient_BeginCancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewExperimentsClient().BeginCancel(ctx, "exampleRG", "exampleExperiment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/StartAExperiment.json +func ExampleExperimentsClient_Start() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewExperimentsClient().Start(ctx, "exampleRG", "exampleExperiment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentStatuses.json +func ExampleExperimentsClient_NewListAllStatusesPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewExperimentsClient().NewListAllStatusesPager("exampleRG", "exampleExperiment", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ExperimentStatusListResult = armchaos.ExperimentStatusListResult{ + // Value: []*armchaos.ExperimentStatus{ + // { + // Name: to.Ptr("50734542-2e64-4e08-814c-cc0e7475f7e4"), + // Type: to.Ptr("Microsoft.Chaos/experiments/statuses"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/statuses/50734542-2e64-4e08-814c-cc0e7475f7e4"), + // Properties: &armchaos.ExperimentStatusProperties{ + // CreatedDateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // EndDateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T01:00:00.0Z"); return t}()), + // Status: to.Ptr("Successful"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentStatus.json +func ExampleExperimentsClient_GetStatus() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExperimentsClient().GetStatus(ctx, "exampleRG", "exampleExperiment", "50734542-2e64-4e08-814c-cc0e7475f7e4", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ExperimentStatus = armchaos.ExperimentStatus{ + // Name: to.Ptr("50734542-2e64-4e08-814c-cc0e7475f7e4"), + // Type: to.Ptr("Microsoft.Chaos/experiments/statuses"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/statuses/50734542-2e64-4e08-814c-cc0e7475f7e4"), + // Properties: &armchaos.ExperimentStatusProperties{ + // CreatedDateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // EndDateUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T01:00:00.0Z"); return t}()), + // Status: to.Ptr("Successful"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentExecutionsDetails.json +func ExampleExperimentsClient_NewListExecutionDetailsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewExperimentsClient().NewListExecutionDetailsPager("exampleRG", "exampleExperiment", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ExperimentExecutionDetailsListResult = armchaos.ExperimentExecutionDetailsListResult{ + // Value: []*armchaos.ExperimentExecutionDetails{ + // { + // Name: to.Ptr("f24500ad-744e-4a26-864b-b76199eac333"), + // Type: to.Ptr("Microsoft.Chaos/experiments/executionDetails"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/executionDetails/f24500ad-744e-4a26-864b-b76199eac333"), + // Properties: &armchaos.ExperimentExecutionDetailsProperties{ + // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:42.917983Z"); return t}()), + // ExperimentID: to.Ptr("f24500ad-744e-4a26-864b-b76199eac333"), + // FailureReason: to.Ptr("Dependency failure"), + // LastActionDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.2552574Z"); return t}()), + // RunInformation: &armchaos.ExperimentExecutionDetailsPropertiesRunInformation{ + // Steps: []*armchaos.StepStatus{ + // { + // Branches: []*armchaos.BranchStatus{ + // { + // Actions: []*armchaos.ActionStatus{ + // { + // ActionID: to.Ptr("59499d33-6751-4b6e-a1f6-58f4d56a040a"), + // ActionName: to.Ptr("urn:provider:agent-v2:Microsoft.Azure.Chaos.Fault.CPUPressureAllProcessors"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T13:56:13.6270153-08:00"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T13:56:13.6270153-08:00"); return t}()), + // Status: to.Ptr("failed"), + // Targets: []*armchaos.ExperimentExecutionActionTargetDetailsProperties{ + // { + // Status: to.Ptr("succeeded"), + // Target: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/VM1"), + // TargetCompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T17:30:55+00:00"); return t}()), + // TargetFailedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T16:30:55+00:00"); return t}()), + // }}, + // }}, + // BranchID: to.Ptr("FirstBranch"), + // BranchName: to.Ptr("FirstBranch"), + // Status: to.Ptr("failed"), + // }}, + // Status: to.Ptr("failed"), + // StepID: to.Ptr("FirstStep"), + // StepName: to.Ptr("FirstStep"), + // }}, + // }, + // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.2552574Z"); return t}()), + // Status: to.Ptr("failed"), + // StopDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:18.9281956Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("14d98367-52ef-4596-be4f-53fc81bbfc33"), + // Type: to.Ptr("Microsoft.Chaos/experiments/executionDetails"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/executionDetails/14d98367-52ef-4596-be4f-53fc81bbfc33"), + // Properties: &armchaos.ExperimentExecutionDetailsProperties{ + // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:42.917983Z"); return t}()), + // ExperimentID: to.Ptr("14d98367-52ef-4596-be4f-53fc81bbfc33"), + // FailureReason: to.Ptr(""), + // LastActionDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.2552574Z"); return t}()), + // RunInformation: &armchaos.ExperimentExecutionDetailsPropertiesRunInformation{ + // Steps: []*armchaos.StepStatus{ + // { + // Branches: []*armchaos.BranchStatus{ + // { + // Actions: []*armchaos.ActionStatus{ + // { + // ActionID: to.Ptr("59499d33-6751-4b6e-a1f6-58f4d56a040a"), + // ActionName: to.Ptr("urn:provider:agent-v2:Microsoft.Azure.Chaos.Fault.CPUPressureAllProcessors"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T13:56:13.6270153-08:00"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T13:56:13.6270153-08:00"); return t}()), + // Status: to.Ptr("success"), + // Targets: []*armchaos.ExperimentExecutionActionTargetDetailsProperties{ + // { + // Status: to.Ptr("succeeded"), + // Target: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/VM1"), + // TargetCompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T17:30:55+00:00"); return t}()), + // TargetFailedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T16:30:55+00:00"); return t}()), + // }}, + // }}, + // BranchID: to.Ptr("FirstBranch"), + // BranchName: to.Ptr("FirstBranch"), + // Status: to.Ptr("success"), + // }}, + // Status: to.Ptr("success"), + // StepID: to.Ptr("FirstStep"), + // StepName: to.Ptr("FirstStep"), + // }}, + // }, + // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.2552574Z"); return t}()), + // Status: to.Ptr("success"), + // StopDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:18.9281956Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentExecutionDetails.json +func ExampleExperimentsClient_GetExecutionDetails() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExperimentsClient().GetExecutionDetails(ctx, "exampleRG", "exampleExperiment", "f24500ad-744e-4a26-864b-b76199eac333", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ExperimentExecutionDetails = armchaos.ExperimentExecutionDetails{ + // Name: to.Ptr("f24500ad-744e-4a26-864b-b76199eac333"), + // Type: to.Ptr("Microsoft.Chaos/experiments/executionDetails"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/executionDetails/f24500ad-744e-4a26-864b-b76199eac333"), + // } +} diff --git a/sdk/resourcemanager/chaos/armchaos/go.mod b/sdk/resourcemanager/chaos/armchaos/go.mod index 2cad5279935a..951d95fc0ae1 100644 --- a/sdk/resourcemanager/chaos/armchaos/go.mod +++ b/sdk/resourcemanager/chaos/armchaos/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/chaos/armchaos/go.sum b/sdk/resourcemanager/chaos/armchaos/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/chaos/armchaos/go.sum +++ b/sdk/resourcemanager/chaos/armchaos/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_models.go b/sdk/resourcemanager/chaos/armchaos/models.go similarity index 97% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_models.go rename to sdk/resourcemanager/chaos/armchaos/models.go index fe1c7593af6b..10369e57efd6 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_models.go +++ b/sdk/resourcemanager/chaos/armchaos/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -91,7 +92,7 @@ type CapabilitiesClientGetOptions struct { // placeholder for future optional parameters } -// CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.List method. +// CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.NewListPager method. type CapabilitiesClientListOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -198,7 +199,7 @@ type CapabilityTypesClientGetOptions struct { // placeholder for future optional parameters } -// CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.List method. +// CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.NewListPager method. type CapabilityTypesClientListOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -276,7 +277,7 @@ func (d *DiscreteAction) GetAction() *Action { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -528,7 +529,7 @@ type ExperimentsClientGetStatusOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.ListAll method. +// ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.NewListAllPager method. type ExperimentsClientListAllOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -537,18 +538,19 @@ type ExperimentsClientListAllOptions struct { Running *bool } -// ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.ListAllStatuses method. +// ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.NewListAllStatusesPager +// method. type ExperimentsClientListAllStatusesOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.ListExecutionDetails +// ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.NewListExecutionDetailsPager // method. type ExperimentsClientListExecutionDetailsOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.List method. +// ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.NewListPager method. type ExperimentsClientListOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -620,7 +622,7 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty" azure:"ro"` } -// OperationsClientListAllOptions contains the optional parameters for the OperationsClient.ListAll method. +// OperationsClientListAllOptions contains the optional parameters for the OperationsClient.NewListAllPager method. type OperationsClientListAllOptions struct { // placeholder for future optional parameters } @@ -709,7 +711,7 @@ type SystemData struct { // Target - Model that represents a Target resource. type Target struct { // REQUIRED; The properties of the target resource. - Properties map[string]interface{} `json:"properties,omitempty"` + Properties map[string]any `json:"properties,omitempty"` // Location of the target resource. Location *string `json:"location,omitempty"` @@ -741,7 +743,8 @@ type TargetReference struct { // REQUIRED; String of the resource ID of a Target resource. ID *string `json:"id,omitempty"` - // REQUIRED; Enum of the Target reference type. + // CONSTANT; Enum of the Target reference type. + // Field has constant value "ChaosTarget", any specified value is ignored. Type *string `json:"type,omitempty"` } @@ -795,7 +798,7 @@ type TargetTypesClientGetOptions struct { // placeholder for future optional parameters } -// TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.List method. +// TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.NewListPager method. type TargetTypesClientListOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -816,7 +819,7 @@ type TargetsClientGetOptions struct { // placeholder for future optional parameters } -// TargetsClientListOptions contains the optional parameters for the TargetsClient.List method. +// TargetsClientListOptions contains the optional parameters for the TargetsClient.NewListPager method. type TargetsClientListOptions struct { // String that sets the continuation token. ContinuationToken *string diff --git a/sdk/resourcemanager/chaos/armchaos/models_serde.go b/sdk/resourcemanager/chaos/armchaos/models_serde.go new file mode 100644 index 000000000000..68cfeabaef60 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/models_serde.go @@ -0,0 +1,1794 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchaos + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Action. +func (a Action) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + objectMap["type"] = a.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Action. +func (a *Action) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ActionStatus. +func (a ActionStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionId", a.ActionID) + populate(objectMap, "actionName", a.ActionName) + populateTimeRFC3339(objectMap, "endTime", a.EndTime) + populateTimeRFC3339(objectMap, "startTime", a.StartTime) + populate(objectMap, "status", a.Status) + populate(objectMap, "targets", a.Targets) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ActionStatus. +func (a *ActionStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionId": + err = unpopulate(val, "ActionID", &a.ActionID) + delete(rawMsg, key) + case "actionName": + err = unpopulate(val, "ActionName", &a.ActionName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "targets": + err = unpopulate(val, "Targets", &a.Targets) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Branch. +func (b Branch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actions", b.Actions) + populate(objectMap, "name", b.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Branch. +func (b *Branch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + b.Actions, err = unmarshalActionClassificationArray(val) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BranchStatus. +func (b BranchStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actions", b.Actions) + populate(objectMap, "branchId", b.BranchID) + populate(objectMap, "branchName", b.BranchName) + populate(objectMap, "status", b.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BranchStatus. +func (b *BranchStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, "Actions", &b.Actions) + delete(rawMsg, key) + case "branchId": + err = unpopulate(val, "BranchID", &b.BranchID) + delete(rawMsg, key) + case "branchName": + err = unpopulate(val, "BranchName", &b.BranchName) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Capability. +func (c Capability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Capability. +func (c *Capability) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityListResult. +func (c CapabilityListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityListResult. +func (c *CapabilityListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityProperties. +func (c CapabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", c.Description) + populate(objectMap, "parametersSchema", c.ParametersSchema) + populate(objectMap, "publisher", c.Publisher) + populate(objectMap, "targetType", c.TargetType) + populate(objectMap, "urn", c.Urn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityProperties. +func (c *CapabilityProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "parametersSchema": + err = unpopulate(val, "ParametersSchema", &c.ParametersSchema) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &c.Publisher) + delete(rawMsg, key) + case "targetType": + err = unpopulate(val, "TargetType", &c.TargetType) + delete(rawMsg, key) + case "urn": + err = unpopulate(val, "Urn", &c.Urn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityType. +func (c CapabilityType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityType. +func (c *CapabilityType) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityTypeListResult. +func (c CapabilityTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityTypeListResult. +func (c *CapabilityTypeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityTypeProperties. +func (c CapabilityTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", c.Description) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "parametersSchema", c.ParametersSchema) + populate(objectMap, "publisher", c.Publisher) + populate(objectMap, "targetType", c.TargetType) + populate(objectMap, "urn", c.Urn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityTypeProperties. +func (c *CapabilityTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "parametersSchema": + err = unpopulate(val, "ParametersSchema", &c.ParametersSchema) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &c.Publisher) + delete(rawMsg, key) + case "targetType": + err = unpopulate(val, "TargetType", &c.TargetType) + delete(rawMsg, key) + case "urn": + err = unpopulate(val, "Urn", &c.Urn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContinuousAction. +func (c ContinuousAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "duration", c.Duration) + populate(objectMap, "name", c.Name) + populate(objectMap, "parameters", c.Parameters) + populate(objectMap, "selectorId", c.SelectorID) + objectMap["type"] = "continuous" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContinuousAction. +func (c *ContinuousAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "duration": + err = unpopulate(val, "Duration", &c.Duration) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &c.Parameters) + delete(rawMsg, key) + case "selectorId": + err = unpopulate(val, "SelectorID", &c.SelectorID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DelayAction. +func (d DelayAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "duration", d.Duration) + populate(objectMap, "name", d.Name) + objectMap["type"] = "delay" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DelayAction. +func (d *DelayAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "duration": + err = unpopulate(val, "Duration", &d.Duration) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscreteAction. +func (d DiscreteAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", d.Name) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "selectorId", d.SelectorID) + objectMap["type"] = "discrete" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscreteAction. +func (d *DiscreteAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "selectorId": + err = unpopulate(val, "SelectorID", &d.SelectorID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Experiment. +func (e Experiment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Experiment. +func (e *Experiment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentCancelOperationResult. +func (e ExperimentCancelOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", e.Name) + populate(objectMap, "statusUrl", e.StatusURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentCancelOperationResult. +func (e *ExperimentCancelOperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "statusUrl": + err = unpopulate(val, "StatusURL", &e.StatusURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionActionTargetDetailsError. +func (e ExperimentExecutionActionTargetDetailsError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionActionTargetDetailsError. +func (e *ExperimentExecutionActionTargetDetailsError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionActionTargetDetailsProperties. +func (e ExperimentExecutionActionTargetDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + populate(objectMap, "status", e.Status) + populate(objectMap, "target", e.Target) + populateTimeRFC3339(objectMap, "targetCompletedTime", e.TargetCompletedTime) + populateTimeRFC3339(objectMap, "targetFailedTime", e.TargetFailedTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionActionTargetDetailsProperties. +func (e *ExperimentExecutionActionTargetDetailsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + case "targetCompletedTime": + err = unpopulateTimeRFC3339(val, "TargetCompletedTime", &e.TargetCompletedTime) + delete(rawMsg, key) + case "targetFailedTime": + err = unpopulateTimeRFC3339(val, "TargetFailedTime", &e.TargetFailedTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetails. +func (e ExperimentExecutionDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetails. +func (e *ExperimentExecutionDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsListResult. +func (e ExperimentExecutionDetailsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsListResult. +func (e *ExperimentExecutionDetailsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsProperties. +func (e ExperimentExecutionDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDateTime", e.CreatedDateTime) + populate(objectMap, "experimentId", e.ExperimentID) + populate(objectMap, "failureReason", e.FailureReason) + populateTimeRFC3339(objectMap, "lastActionDateTime", e.LastActionDateTime) + populate(objectMap, "runInformation", e.RunInformation) + populateTimeRFC3339(objectMap, "startDateTime", e.StartDateTime) + populate(objectMap, "status", e.Status) + populateTimeRFC3339(objectMap, "stopDateTime", e.StopDateTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsProperties. +func (e *ExperimentExecutionDetailsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdDateTime": + err = unpopulateTimeRFC3339(val, "CreatedDateTime", &e.CreatedDateTime) + delete(rawMsg, key) + case "experimentId": + err = unpopulate(val, "ExperimentID", &e.ExperimentID) + delete(rawMsg, key) + case "failureReason": + err = unpopulate(val, "FailureReason", &e.FailureReason) + delete(rawMsg, key) + case "lastActionDateTime": + err = unpopulateTimeRFC3339(val, "LastActionDateTime", &e.LastActionDateTime) + delete(rawMsg, key) + case "runInformation": + err = unpopulate(val, "RunInformation", &e.RunInformation) + delete(rawMsg, key) + case "startDateTime": + err = unpopulateTimeRFC3339(val, "StartDateTime", &e.StartDateTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "stopDateTime": + err = unpopulateTimeRFC3339(val, "StopDateTime", &e.StopDateTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsPropertiesRunInformation. +func (e ExperimentExecutionDetailsPropertiesRunInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "steps", e.Steps) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsPropertiesRunInformation. +func (e *ExperimentExecutionDetailsPropertiesRunInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "steps": + err = unpopulate(val, "Steps", &e.Steps) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentListResult. +func (e ExperimentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentListResult. +func (e *ExperimentListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentProperties. +func (e ExperimentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "selectors", e.Selectors) + populate(objectMap, "startOnCreation", e.StartOnCreation) + populate(objectMap, "steps", e.Steps) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentProperties. +func (e *ExperimentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "selectors": + err = unpopulate(val, "Selectors", &e.Selectors) + delete(rawMsg, key) + case "startOnCreation": + err = unpopulate(val, "StartOnCreation", &e.StartOnCreation) + delete(rawMsg, key) + case "steps": + err = unpopulate(val, "Steps", &e.Steps) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStartOperationResult. +func (e ExperimentStartOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", e.Name) + populate(objectMap, "statusUrl", e.StatusURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStartOperationResult. +func (e *ExperimentStartOperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "statusUrl": + err = unpopulate(val, "StatusURL", &e.StatusURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatus. +func (e ExperimentStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatus. +func (e *ExperimentStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatusListResult. +func (e ExperimentStatusListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatusListResult. +func (e *ExperimentStatusListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatusProperties. +func (e ExperimentStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDateUtc", e.CreatedDateUTC) + populateTimeRFC3339(objectMap, "endDateUtc", e.EndDateUTC) + populate(objectMap, "status", e.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatusProperties. +func (e *ExperimentStatusProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdDateUtc": + err = unpopulateTimeRFC3339(val, "CreatedDateUTC", &e.CreatedDateUTC) + delete(rawMsg, key) + case "endDateUtc": + err = unpopulateTimeRFC3339(val, "EndDateUTC", &e.EndDateUTC) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyValuePair. +func (k KeyValuePair) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "key", k.Key) + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyValuePair. +func (k *KeyValuePair) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "key": + err = unpopulate(val, "Key", &k.Key) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceIdentity. +func (r ResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", r.PrincipalID) + populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceIdentity. +func (r *ResourceIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &r.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Selector. +func (s Selector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "targets", s.Targets) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Selector. +func (s *Selector) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "targets": + err = unpopulate(val, "Targets", &s.Targets) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Step. +func (s Step) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branches", s.Branches) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Step. +func (s *Step) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branches": + err = unpopulate(val, "Branches", &s.Branches) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StepStatus. +func (s StepStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branches", s.Branches) + populate(objectMap, "status", s.Status) + populate(objectMap, "stepId", s.StepID) + populate(objectMap, "stepName", s.StepName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StepStatus. +func (s *StepStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branches": + err = unpopulate(val, "Branches", &s.Branches) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "stepId": + err = unpopulate(val, "StepID", &s.StepID) + delete(rawMsg, key) + case "stepName": + err = unpopulate(val, "StepName", &s.StepName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Target. +func (t Target) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Target. +func (t *Target) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetListResult. +func (t TargetListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetListResult. +func (t *TargetListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetReference. +func (t TargetReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + objectMap["type"] = "ChaosTarget" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetReference. +func (t *TargetReference) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetType. +func (t TargetType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetType. +func (t *TargetType) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetTypeListResult. +func (t TargetTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetTypeListResult. +func (t *TargetTypeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetTypeProperties. +func (t TargetTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", t.Description) + populate(objectMap, "displayName", t.DisplayName) + populate(objectMap, "propertiesSchema", t.PropertiesSchema) + populate(objectMap, "resourceTypes", t.ResourceTypes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetTypeProperties. +func (t *TargetTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &t.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &t.DisplayName) + delete(rawMsg, key) + case "propertiesSchema": + err = unpopulate(val, "PropertiesSchema", &t.PropertiesSchema) + delete(rawMsg, key) + case "resourceTypes": + err = unpopulate(val, "ResourceTypes", &t.ResourceTypes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go b/sdk/resourcemanager/chaos/armchaos/operations_client.go similarity index 77% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go rename to sdk/resourcemanager/chaos/armchaos/operations_client.go index 762a432fd8c0..8d82029971d9 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go +++ b/sdk/resourcemanager/chaos/armchaos/operations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListAllPager - Get a list all available Operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// options - OperationsClientListAllOptions contains the optional parameters for the OperationsClient.ListAll method. +// - options - OperationsClientListAllOptions contains the optional parameters for the OperationsClient.NewListAllPager method. func (client *OperationsClient) NewListAllPager(options *OperationsClientListAllOptions) *runtime.Pager[OperationsClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListAllResponse]{ More: func(page OperationsClientListAllResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListAllPager(options *OperationsClientListAll if err != nil { return OperationsClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListAllResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListAllPager(options *OperationsClientListAll // listAllCreateRequest creates the ListAll request. func (client *OperationsClient) listAllCreateRequest(ctx context.Context, options *OperationsClientListAllOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Chaos/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go similarity index 97% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go index b23d5051eeb6..f62d5990a659 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -14,7 +15,7 @@ func unmarshalActionClassification(rawMsg json.RawMessage) (ActionClassification if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go b/sdk/resourcemanager/chaos/armchaos/response_types.go similarity index 89% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go rename to sdk/resourcemanager/chaos/armchaos/response_types.go index 3d53332ee2ca..97556be7e759 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go +++ b/sdk/resourcemanager/chaos/armchaos/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -23,7 +24,7 @@ type CapabilitiesClientGetResponse struct { Capability } -// CapabilitiesClientListResponse contains the response from method CapabilitiesClient.List. +// CapabilitiesClientListResponse contains the response from method CapabilitiesClient.NewListPager. type CapabilitiesClientListResponse struct { CapabilityListResult } @@ -33,17 +34,17 @@ type CapabilityTypesClientGetResponse struct { CapabilityType } -// CapabilityTypesClientListResponse contains the response from method CapabilityTypesClient.List. +// CapabilityTypesClientListResponse contains the response from method CapabilityTypesClient.NewListPager. type CapabilityTypesClientListResponse struct { CapabilityTypeListResult } -// ExperimentsClientCancelResponse contains the response from method ExperimentsClient.Cancel. +// ExperimentsClientCancelResponse contains the response from method ExperimentsClient.BeginCancel. type ExperimentsClientCancelResponse struct { ExperimentCancelOperationResult } -// ExperimentsClientCreateOrUpdateResponse contains the response from method ExperimentsClient.CreateOrUpdate. +// ExperimentsClientCreateOrUpdateResponse contains the response from method ExperimentsClient.BeginCreateOrUpdate. type ExperimentsClientCreateOrUpdateResponse struct { Experiment } @@ -68,22 +69,22 @@ type ExperimentsClientGetStatusResponse struct { ExperimentStatus } -// ExperimentsClientListAllResponse contains the response from method ExperimentsClient.ListAll. +// ExperimentsClientListAllResponse contains the response from method ExperimentsClient.NewListAllPager. type ExperimentsClientListAllResponse struct { ExperimentListResult } -// ExperimentsClientListAllStatusesResponse contains the response from method ExperimentsClient.ListAllStatuses. +// ExperimentsClientListAllStatusesResponse contains the response from method ExperimentsClient.NewListAllStatusesPager. type ExperimentsClientListAllStatusesResponse struct { ExperimentStatusListResult } -// ExperimentsClientListExecutionDetailsResponse contains the response from method ExperimentsClient.ListExecutionDetails. +// ExperimentsClientListExecutionDetailsResponse contains the response from method ExperimentsClient.NewListExecutionDetailsPager. type ExperimentsClientListExecutionDetailsResponse struct { ExperimentExecutionDetailsListResult } -// ExperimentsClientListResponse contains the response from method ExperimentsClient.List. +// ExperimentsClientListResponse contains the response from method ExperimentsClient.NewListPager. type ExperimentsClientListResponse struct { ExperimentListResult } @@ -93,7 +94,7 @@ type ExperimentsClientStartResponse struct { ExperimentStartOperationResult } -// OperationsClientListAllResponse contains the response from method OperationsClient.ListAll. +// OperationsClientListAllResponse contains the response from method OperationsClient.NewListAllPager. type OperationsClientListAllResponse struct { OperationListResult } @@ -103,7 +104,7 @@ type TargetTypesClientGetResponse struct { TargetType } -// TargetTypesClientListResponse contains the response from method TargetTypesClient.List. +// TargetTypesClientListResponse contains the response from method TargetTypesClient.NewListPager. type TargetTypesClientListResponse struct { TargetTypeListResult } @@ -123,7 +124,7 @@ type TargetsClientGetResponse struct { Target } -// TargetsClientListResponse contains the response from method TargetsClient.List. +// TargetsClientListResponse contains the response from method TargetsClient.NewListPager. type TargetsClientListResponse struct { TargetListResult } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go b/sdk/resourcemanager/chaos/armchaos/targets_client.go similarity index 83% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go rename to sdk/resourcemanager/chaos/armchaos/targets_client.go index d7e9fad2262f..ec0e0dd907dc 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go +++ b/sdk/resourcemanager/chaos/armchaos/targets_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,51 +24,43 @@ import ( // TargetsClient contains the methods for the Targets group. // Don't use this type directly, use NewTargetsClient() instead. type TargetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTargetsClient creates a new instance of TargetsClient with the specified values. -// subscriptionID - GUID that represents an Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - GUID that represents an Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTargetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TargetsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TargetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TargetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update a Target resource that extends a tracked regional resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// targetName - String that represents a Target resource name. -// target - Target resource to be created or updated. -// options - TargetsClientCreateOrUpdateOptions contains the optional parameters for the TargetsClient.CreateOrUpdate method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - targetName - String that represents a Target resource name. +// - target - Target resource to be created or updated. +// - options - TargetsClientCreateOrUpdateOptions contains the optional parameters for the TargetsClient.CreateOrUpdate method. func (client *TargetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, target Target, options *TargetsClientCreateOrUpdateOptions) (TargetsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, target, options) if err != nil { return TargetsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TargetsClientCreateOrUpdateResponse{}, err } @@ -106,7 +97,7 @@ func (client *TargetsClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, errors.New("parameter targetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,19 +119,20 @@ func (client *TargetsClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Delete a Target resource that extends a tracked regional resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// targetName - String that represents a Target resource name. -// options - TargetsClientDeleteOptions contains the optional parameters for the TargetsClient.Delete method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - targetName - String that represents a Target resource name. +// - options - TargetsClientDeleteOptions contains the optional parameters for the TargetsClient.Delete method. func (client *TargetsClient) Delete(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsClientDeleteOptions) (TargetsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) if err != nil { return TargetsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TargetsClientDeleteResponse{}, err } @@ -177,7 +169,7 @@ func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter targetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -190,19 +182,20 @@ func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Get a Target resource that extends a tracked regional resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// targetName - String that represents a Target resource name. -// options - TargetsClientGetOptions contains the optional parameters for the TargetsClient.Get method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - targetName - String that represents a Target resource name. +// - options - TargetsClientGetOptions contains the optional parameters for the TargetsClient.Get method. func (client *TargetsClient) Get(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsClientGetOptions) (TargetsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) if err != nil { return TargetsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TargetsClientGetResponse{}, err } @@ -239,7 +232,7 @@ func (client *TargetsClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter targetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{targetName}", url.PathEscape(targetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -260,13 +253,13 @@ func (client *TargetsClient) getHandleResponse(resp *http.Response) (TargetsClie } // NewListPager - Get a list of Target resources that extend a tracked regional resource. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// parentProviderNamespace - String that represents a resource provider namespace. -// parentResourceType - String that represents a resource type. -// parentResourceName - String that represents a resource name. -// options - TargetsClientListOptions contains the optional parameters for the TargetsClient.List method. +// - resourceGroupName - String that represents an Azure resource group. +// - parentProviderNamespace - String that represents a resource provider namespace. +// - parentResourceType - String that represents a resource type. +// - parentResourceName - String that represents a resource name. +// - options - TargetsClientListOptions contains the optional parameters for the TargetsClient.NewListPager method. func (client *TargetsClient) NewListPager(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, options *TargetsClientListOptions) *runtime.Pager[TargetsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TargetsClientListResponse]{ More: func(page TargetsClientListResponse) bool { @@ -283,7 +276,7 @@ func (client *TargetsClient) NewListPager(resourceGroupName string, parentProvid if err != nil { return TargetsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TargetsClientListResponse{}, err } @@ -318,7 +311,7 @@ func (client *TargetsClient) listCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter parentResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/chaos/armchaos/targets_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/targets_client_example_test.go new file mode 100644 index 000000000000..a56f577772b9 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/targets_client_example_test.go @@ -0,0 +1,169 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListTargets.json +func ExampleTargetsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTargetsClient().NewListPager("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", &armchaos.TargetsClientListOptions{ContinuationToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TargetListResult = armchaos.TargetListResult{ + // Value: []*armchaos.Target{ + // { + // Name: to.Ptr("Microsoft-Agent"), + // Type: to.Ptr("Microsoft.Chaos/targets"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-Agent"), + // Location: to.Ptr("centraluseuap"), + // Properties: map[string]any{ + // "agentProfileId": "ac4e8251-fdc9-4277-8e87-dc57fe5794cf", + // "identities": []any{ + // map[string]any{ + // "type": "CertificateSubjectIssuer", + // "subject": "CN=example.subject", + // }, + // }, + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATarget.json +func ExampleTargetsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTargetsClient().Get(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Target = armchaos.Target{ + // Name: to.Ptr("Microsoft-Agent"), + // Type: to.Ptr("Microsoft.Chaos/targets"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-Agent"), + // Location: to.Ptr("centraluseuap"), + // Properties: map[string]any{ + // "agentProfileId": "ac4e8251-fdc9-4277-8e87-dc57fe5794cf", + // "identities": []any{ + // map[string]any{ + // "type": "CertificateSubjectIssuer", + // "subject": "CN=example.subject", + // }, + // }, + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteATarget.json +func ExampleTargetsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewTargetsClient().Delete(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateATarget.json +func ExampleTargetsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTargetsClient().CreateOrUpdate(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent", armchaos.Target{ + Properties: map[string]any{ + "identities": []any{ + map[string]any{ + "type": "CertificateSubjectIssuer", + "subject": "CN=example.subject", + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Target = armchaos.Target{ + // Name: to.Ptr("Microsoft-Agent"), + // Type: to.Ptr("Microsoft.Chaos/targets"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-Agent"), + // Location: to.Ptr("centraluseuap"), + // Properties: map[string]any{ + // "agentProfileId": "ac4e8251-fdc9-4277-8e87-dc57fe5794cf", + // "identities": []any{ + // map[string]any{ + // "type": "CertificateSubjectIssuer", + // "subject": "CN=example.subject", + // }, + // }, + // }, + // SystemData: &armchaos.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.0Z"); return t}()), + // }, + // } +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go b/sdk/resourcemanager/chaos/armchaos/targettypes_client.go similarity index 81% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go rename to sdk/resourcemanager/chaos/armchaos/targettypes_client.go index 02b1bcd841de..9a2dd5432f2d 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go +++ b/sdk/resourcemanager/chaos/armchaos/targettypes_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,47 +24,39 @@ import ( // TargetTypesClient contains the methods for the TargetTypes group. // Don't use this type directly, use NewTargetTypesClient() instead. type TargetTypesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTargetTypesClient creates a new instance of TargetTypesClient with the specified values. -// subscriptionID - GUID that represents an Azure subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - GUID that represents an Azure subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTargetTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TargetTypesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TargetTypesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TargetTypesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get a Target Type resources for given location. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// locationName - String that represents a Location resource name. -// targetTypeName - String that represents a Target Type resource name. -// options - TargetTypesClientGetOptions contains the optional parameters for the TargetTypesClient.Get method. +// - locationName - String that represents a Location resource name. +// - targetTypeName - String that represents a Target Type resource name. +// - options - TargetTypesClientGetOptions contains the optional parameters for the TargetTypesClient.Get method. func (client *TargetTypesClient) Get(ctx context.Context, locationName string, targetTypeName string, options *TargetTypesClientGetOptions) (TargetTypesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, locationName, targetTypeName, options) if err != nil { return TargetTypesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TargetTypesClientGetResponse{}, err } @@ -90,7 +81,7 @@ func (client *TargetTypesClient) getCreateRequest(ctx context.Context, locationN return nil, errors.New("parameter targetTypeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{targetTypeName}", url.PathEscape(targetTypeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -111,10 +102,10 @@ func (client *TargetTypesClient) getHandleResponse(resp *http.Response) (TargetT } // NewListPager - Get a list of Target Type resources for given location. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-09-15-preview -// locationName - String that represents a Location resource name. -// options - TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.List method. +// - locationName - String that represents a Location resource name. +// - options - TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.NewListPager method. func (client *TargetTypesClient) NewListPager(locationName string, options *TargetTypesClientListOptions) *runtime.Pager[TargetTypesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TargetTypesClientListResponse]{ More: func(page TargetTypesClientListResponse) bool { @@ -131,7 +122,7 @@ func (client *TargetTypesClient) NewListPager(locationName string, options *Targ if err != nil { return TargetTypesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TargetTypesClientListResponse{}, err } @@ -154,7 +145,7 @@ func (client *TargetTypesClient) listCreateRequest(ctx context.Context, location return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/chaos/armchaos/targettypes_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/targettypes_client_example_test.go new file mode 100644 index 000000000000..4c3c81028315 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/targettypes_client_example_test.go @@ -0,0 +1,94 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armchaos_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListTargetTypes.json +func ExampleTargetTypesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTargetTypesClient().NewListPager("westus2", &armchaos.TargetTypesClientListOptions{ContinuationToken: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TargetTypeListResult = armchaos.TargetTypeListResult{ + // Value: []*armchaos.TargetType{ + // { + // Name: to.Ptr("Microsoft-Agent"), + // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/providers/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-Agent"), + // Location: to.Ptr("centraluseuap"), + // Properties: &armchaos.TargetTypeProperties{ + // Description: to.Ptr("A target represents Chaos Agent."), + // DisplayName: to.Ptr("Chaos Agent"), + // PropertiesSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine.json"), + // ResourceTypes: []*string{ + // to.Ptr("Microsoft.Compute/virtualMachines"), + // to.Ptr("Microsoft.Compute/virtualMachineScaleSets")}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATargetType.json +func ExampleTargetTypesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armchaos.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTargetTypesClient().Get(ctx, "westus2", "Microsoft-Agent", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TargetType = armchaos.TargetType{ + // Name: to.Ptr("Microsoft-Agent"), + // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes"), + // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/providers/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-Agent"), + // Location: to.Ptr("centraluseuap"), + // Properties: &armchaos.TargetTypeProperties{ + // Description: to.Ptr("A target represents Chaos Agent."), + // DisplayName: to.Ptr("Chaos Agent"), + // PropertiesSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine.json"), + // ResourceTypes: []*string{ + // to.Ptr("Microsoft.Compute/virtualMachines"), + // to.Ptr("Microsoft.Compute/virtualMachineScaleSets")}, + // }, + // } +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go b/sdk/resourcemanager/chaos/armchaos/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/chaos/armchaos/time_rfc3339.go index 6213a56e2f08..13c031ec6d72 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/chaos/armchaos/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go deleted file mode 100644 index a9d07468a7a2..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go +++ /dev/null @@ -1,125 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListCapabilities.json -func ExampleCapabilitiesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-VirtualMachine", - &armchaos.CapabilitiesClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapability.json -func ExampleCapabilitiesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-VirtualMachine", - "Shutdown-1.0", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteACapability.json -func ExampleCapabilitiesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-VirtualMachine", - "Shutdown-1.0", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateACapability.json -func ExampleCapabilitiesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-VirtualMachine", - "Shutdown-1.0", - armchaos.Capability{ - Properties: &armchaos.CapabilityProperties{}, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go deleted file mode 100644 index 8f10a8517638..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListCapabilityTypes.json -func ExampleCapabilityTypesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilityTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - "Microsoft-VirtualMachine", - &armchaos.CapabilityTypesClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapabilityType.json -func ExampleCapabilityTypesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilityTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "Microsoft-VirtualMachine", - "Shutdown-1.0", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go deleted file mode 100644 index 0d6994ba09a6..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go +++ /dev/null @@ -1,312 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentsInASubscription.json -func ExampleExperimentsClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAllPager(&armchaos.ExperimentsClientListAllOptions{Running: nil, - ContinuationToken: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentsInAResourceGroup.json -func ExampleExperimentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("exampleRG", - &armchaos.ExperimentsClientListOptions{Running: nil, - ContinuationToken: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteAExperiment.json -func ExampleExperimentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "exampleRG", - "exampleExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperiment.json -func ExampleExperimentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "exampleRG", - "exampleExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateAExperiment.json -func ExampleExperimentsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "exampleRG", - "exampleExperiment", - armchaos.Experiment{ - Location: to.Ptr("centraluseuap"), - Identity: &armchaos.ResourceIdentity{ - Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armchaos.ExperimentProperties{ - Selectors: []*armchaos.Selector{ - { - Type: to.Ptr(armchaos.SelectorTypeList), - ID: to.Ptr("selector1"), - Targets: []*armchaos.TargetReference{ - { - Type: to.Ptr("ChaosTarget"), - ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), - }}, - }}, - Steps: []*armchaos.Step{ - { - Name: to.Ptr("step1"), - Branches: []*armchaos.Branch{ - { - Name: to.Ptr("branch1"), - Actions: []armchaos.ActionClassification{ - &armchaos.Action{ - Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), - Type: to.Ptr("Continuous"), - }}, - }}, - }}, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CancelAExperiment.json -func ExampleExperimentsClient_BeginCancel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCancel(ctx, - "exampleRG", - "exampleExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/StartAExperiment.json -func ExampleExperimentsClient_Start() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Start(ctx, - "exampleRG", - "exampleExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentStatuses.json -func ExampleExperimentsClient_NewListAllStatusesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAllStatusesPager("exampleRG", - "exampleExperiment", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentStatus.json -func ExampleExperimentsClient_GetStatus() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetStatus(ctx, - "exampleRG", - "exampleExperiment", - "50734542-2e64-4e08-814c-cc0e7475f7e4", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentExecutionsDetails.json -func ExampleExperimentsClient_NewListExecutionDetailsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListExecutionDetailsPager("exampleRG", - "exampleExperiment", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentExecutionDetails.json -func ExampleExperimentsClient_GetExecutionDetails() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetExecutionDetails(ctx, - "exampleRG", - "exampleExperiment", - "f24500ad-744e-4a26-864b-b76199eac333", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go deleted file mode 100644 index 74c3435cc083..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go +++ /dev/null @@ -1,128 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListTargets.json -func ExampleTargetsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - &armchaos.TargetsClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATarget.json -func ExampleTargetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-Agent", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteATarget.json -func ExampleTargetsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-Agent", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateATarget.json -func ExampleTargetsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-Agent", - armchaos.Target{ - Properties: map[string]interface{}{ - "identities": []interface{}{ - map[string]interface{}{ - "type": "CertificateSubjectIssuer", - "subject": "CN=example.subject", - }, - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go deleted file mode 100644 index 7e63882fa8fb..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListTargetTypes.json -func ExampleTargetTypesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - &armchaos.TargetTypesClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATargetType.json -func ExampleTargetTypesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "Microsoft-Agent", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go deleted file mode 100644 index 74d39b994d02..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go +++ /dev/null @@ -1,438 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchaos - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// UnmarshalJSON implements the json.Unmarshaller interface for type ActionStatus. -func (a *ActionStatus) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "actionId": - err = unpopulate(val, "ActionID", &a.ActionID) - delete(rawMsg, key) - case "actionName": - err = unpopulate(val, "ActionName", &a.ActionName) - delete(rawMsg, key) - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &a.Status) - delete(rawMsg, key) - case "targets": - err = unpopulate(val, "Targets", &a.Targets) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Branch. -func (b Branch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "actions", b.Actions) - populate(objectMap, "name", b.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Branch. -func (b *Branch) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "actions": - b.Actions, err = unmarshalActionClassificationArray(val) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &b.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ContinuousAction. -func (c ContinuousAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "duration", c.Duration) - populate(objectMap, "name", c.Name) - populate(objectMap, "parameters", c.Parameters) - populate(objectMap, "selectorId", c.SelectorID) - objectMap["type"] = "continuous" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ContinuousAction. -func (c *ContinuousAction) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "duration": - err = unpopulate(val, "Duration", &c.Duration) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &c.Parameters) - delete(rawMsg, key) - case "selectorId": - err = unpopulate(val, "SelectorID", &c.SelectorID) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DelayAction. -func (d DelayAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "duration", d.Duration) - populate(objectMap, "name", d.Name) - objectMap["type"] = "delay" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DelayAction. -func (d *DelayAction) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "duration": - err = unpopulate(val, "Duration", &d.Duration) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DiscreteAction. -func (d DiscreteAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "name", d.Name) - populate(objectMap, "parameters", d.Parameters) - populate(objectMap, "selectorId", d.SelectorID) - objectMap["type"] = "discrete" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DiscreteAction. -func (d *DiscreteAction) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &d.Parameters) - delete(rawMsg, key) - case "selectorId": - err = unpopulate(val, "SelectorID", &d.SelectorID) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Experiment. -func (e Experiment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", e.ID) - populate(objectMap, "identity", e.Identity) - populate(objectMap, "location", e.Location) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "systemData", e.SystemData) - populate(objectMap, "tags", e.Tags) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionActionTargetDetailsProperties. -func (e *ExperimentExecutionActionTargetDetailsProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &e.Target) - delete(rawMsg, key) - case "targetCompletedTime": - err = unpopulateTimeRFC3339(val, "TargetCompletedTime", &e.TargetCompletedTime) - delete(rawMsg, key) - case "targetFailedTime": - err = unpopulateTimeRFC3339(val, "TargetFailedTime", &e.TargetFailedTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsProperties. -func (e *ExperimentExecutionDetailsProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdDateTime": - err = unpopulateTimeRFC3339(val, "CreatedDateTime", &e.CreatedDateTime) - delete(rawMsg, key) - case "experimentId": - err = unpopulate(val, "ExperimentID", &e.ExperimentID) - delete(rawMsg, key) - case "failureReason": - err = unpopulate(val, "FailureReason", &e.FailureReason) - delete(rawMsg, key) - case "lastActionDateTime": - err = unpopulateTimeRFC3339(val, "LastActionDateTime", &e.LastActionDateTime) - delete(rawMsg, key) - case "runInformation": - err = unpopulate(val, "RunInformation", &e.RunInformation) - delete(rawMsg, key) - case "startDateTime": - err = unpopulateTimeRFC3339(val, "StartDateTime", &e.StartDateTime) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - case "stopDateTime": - err = unpopulateTimeRFC3339(val, "StopDateTime", &e.StopDateTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExperimentProperties. -func (e ExperimentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "selectors", e.Selectors) - populate(objectMap, "startOnCreation", e.StartOnCreation) - populate(objectMap, "steps", e.Steps) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatusProperties. -func (e *ExperimentStatusProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdDateUtc": - err = unpopulateTimeRFC3339(val, "CreatedDateUTC", &e.CreatedDateUTC) - delete(rawMsg, key) - case "endDateUtc": - err = unpopulateTimeRFC3339(val, "EndDateUTC", &e.EndDateUTC) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Selector. -func (s Selector) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "targets", s.Targets) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Step. -func (s Step) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "branches", s.Branches) - populate(objectMap, "name", s.Name) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Target. -func (t Target) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "properties", t.Properties) - populate(objectMap, "systemData", t.SystemData) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TargetTypeProperties. -func (t TargetTypeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", t.Description) - populate(objectMap, "displayName", t.DisplayName) - populate(objectMap, "propertiesSchema", t.PropertiesSchema) - populate(objectMap, "resourceTypes", t.ResourceTypes) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md index 75bdb004b084..3775af2c8ef4 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.4.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.3.0 (2023-02-24) ### Features Added diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/README.md b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/README.md index a109cab0198a..fec086d061b5 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/README.md +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Cognitive Services modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Cognitive Services module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armcognitiveservices.NewResourceSKUsClient(, cred, nil) +clientFactory, err := armX.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions { +options := armcognitiveservices.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armcognitiveservices.NewResourceSKUsClient(, cred, &options) +clientFactory, err := armcognitiveservices.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewAccountsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go index 965ba921e125..e64d3c2edbd7 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // AccountsClient contains the methods for the Accounts group. // Don't use this type directly, use NewAccountsClient() instead. type AccountsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAccountsClient creates a new instance of AccountsClient with the specified values. @@ -36,21 +33,13 @@ type AccountsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccountsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AccountsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AccountsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,9 +59,9 @@ func (client *AccountsClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[AccountsClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[AccountsClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[AccountsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *AccountsClient) create(ctx context.Context, resourceGroupName stri if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -111,7 +100,7 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -135,9 +124,9 @@ func (client *AccountsClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[AccountsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[AccountsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[AccountsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -150,7 +139,7 @@ func (client *AccountsClient) deleteOperation(ctx context.Context, resourceGroup if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -175,7 +164,7 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,7 +187,7 @@ func (client *AccountsClient) Get(ctx context.Context, resourceGroupName string, if err != nil { return AccountsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientGetResponse{}, err } @@ -223,7 +212,7 @@ func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -263,7 +252,7 @@ func (client *AccountsClient) NewListPager(options *AccountsClientListOptions) * if err != nil { return AccountsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListResponse{}, err } @@ -282,7 +271,7 @@ func (client *AccountsClient) listCreateRequest(ctx context.Context, options *Ac return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -324,7 +313,7 @@ func (client *AccountsClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return AccountsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListByResourceGroupResponse{}, err } @@ -347,7 +336,7 @@ func (client *AccountsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -379,7 +368,7 @@ func (client *AccountsClient) ListKeys(ctx context.Context, resourceGroupName st if err != nil { return AccountsClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListKeysResponse{}, err } @@ -404,7 +393,7 @@ func (client *AccountsClient) listKeysCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -446,7 +435,7 @@ func (client *AccountsClient) NewListModelsPager(resourceGroupName string, accou if err != nil { return AccountsClientListModelsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListModelsResponse{}, err } @@ -473,7 +462,7 @@ func (client *AccountsClient) listModelsCreateRequest(ctx context.Context, resou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -505,7 +494,7 @@ func (client *AccountsClient) ListSKUs(ctx context.Context, resourceGroupName st if err != nil { return AccountsClientListSKUsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListSKUsResponse{}, err } @@ -530,7 +519,7 @@ func (client *AccountsClient) listSKUsCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -562,7 +551,7 @@ func (client *AccountsClient) ListUsages(ctx context.Context, resourceGroupName if err != nil { return AccountsClientListUsagesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListUsagesResponse{}, err } @@ -587,7 +576,7 @@ func (client *AccountsClient) listUsagesCreateRequest(ctx context.Context, resou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -623,7 +612,7 @@ func (client *AccountsClient) RegenerateKey(ctx context.Context, resourceGroupNa if err != nil { return AccountsClientRegenerateKeyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientRegenerateKeyResponse{}, err } @@ -648,7 +637,7 @@ func (client *AccountsClient) regenerateKeyCreateRequest(ctx context.Context, re return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -682,9 +671,9 @@ func (client *AccountsClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[AccountsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[AccountsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[AccountsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -697,7 +686,7 @@ func (client *AccountsClient) update(ctx context.Context, resourceGroupName stri if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -722,7 +711,7 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go index 0283a181bc23..95f0fef2918d 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go @@ -25,11 +25,11 @@ func ExampleAccountsClient_BeginCreate_createAccount() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "myResourceGroup", "testCreate1", armcognitiveservices.Account{ + poller, err := clientFactory.NewAccountsClient().BeginCreate(ctx, "myResourceGroup", "testCreate1", armcognitiveservices.Account{ Identity: &armcognitiveservices.Identity{ Type: to.Ptr(armcognitiveservices.ResourceIdentityTypeSystemAssigned), }, @@ -104,11 +104,11 @@ func ExampleAccountsClient_BeginCreate_createAccountMin() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "myResourceGroup", "testCreate1", armcognitiveservices.Account{ + poller, err := clientFactory.NewAccountsClient().BeginCreate(ctx, "myResourceGroup", "testCreate1", armcognitiveservices.Account{ Identity: &armcognitiveservices.Identity{ Type: to.Ptr(armcognitiveservices.ResourceIdentityTypeSystemAssigned), }, @@ -158,11 +158,11 @@ func ExampleAccountsClient_BeginUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "bvttest", "bingSearch", armcognitiveservices.Account{ + poller, err := clientFactory.NewAccountsClient().BeginUpdate(ctx, "bvttest", "bingSearch", armcognitiveservices.Account{ Location: to.Ptr("global"), SKU: &armcognitiveservices.SKU{ Name: to.Ptr("S2"), @@ -202,11 +202,11 @@ func ExampleAccountsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "PropTest01", nil) + poller, err := clientFactory.NewAccountsClient().BeginDelete(ctx, "myResourceGroup", "PropTest01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -223,11 +223,11 @@ func ExampleAccountsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myAccount", nil) + res, err := clientFactory.NewAccountsClient().Get(ctx, "myResourceGroup", "myAccount", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -262,11 +262,11 @@ func ExampleAccountsClient_NewListByResourceGroupPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("myResourceGroup", nil) + pager := clientFactory.NewAccountsClient().NewListByResourceGroupPager("myResourceGroup", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -326,11 +326,11 @@ func ExampleAccountsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewAccountsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -417,11 +417,11 @@ func ExampleAccountsClient_ListKeys() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListKeys(ctx, "myResourceGroup", "myAccount", nil) + res, err := clientFactory.NewAccountsClient().ListKeys(ctx, "myResourceGroup", "myAccount", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -441,11 +441,11 @@ func ExampleAccountsClient_RegenerateKey() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.RegenerateKey(ctx, "myResourceGroup", "myAccount", armcognitiveservices.RegenerateKeyParameters{ + res, err := clientFactory.NewAccountsClient().RegenerateKey(ctx, "myResourceGroup", "myAccount", armcognitiveservices.RegenerateKeyParameters{ KeyName: to.Ptr(armcognitiveservices.KeyNameKey2), }, nil) if err != nil { @@ -467,11 +467,11 @@ func ExampleAccountsClient_ListSKUs() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListSKUs(ctx, "myResourceGroup", "myAccount", nil) + res, err := clientFactory.NewAccountsClient().ListSKUs(ctx, "myResourceGroup", "myAccount", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -504,11 +504,11 @@ func ExampleAccountsClient_ListUsages() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("5a4f5c2e-6983-4ccb-bd34-2196d5b5bbd3", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListUsages(ctx, "myResourceGroup", "TestUsage02", &armcognitiveservices.AccountsClientListUsagesOptions{Filter: nil}) + res, err := clientFactory.NewAccountsClient().ListUsages(ctx, "myResourceGroup", "TestUsage02", &armcognitiveservices.AccountsClientListUsagesOptions{Filter: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -539,11 +539,11 @@ func ExampleAccountsClient_NewListModelsPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewAccountsClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListModelsPager("resourceGroupName", "accountName", nil) + pager := clientFactory.NewAccountsClient().NewListModelsPager("resourceGroupName", "accountName", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md index 5b25630ecfd7..36919477a110 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/cognitiveservices/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/cognitiveservices/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.3.0 +module-version: 1.4.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/client_factory.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/client_factory.go new file mode 100644 index 000000000000..bcbdf82b0b84 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/client_factory.go @@ -0,0 +1,89 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armcognitiveservices + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAccountsClient() *AccountsClient { + subClient, _ := NewAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeletedAccountsClient() *DeletedAccountsClient { + subClient, _ := NewDeletedAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourceSKUsClient() *ResourceSKUsClient { + subClient, _ := NewResourceSKUsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewManagementClient() *ManagementClient { + subClient, _ := NewManagementClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCommitmentTiersClient() *CommitmentTiersClient { + subClient, _ := NewCommitmentTiersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { + subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { + subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { + subClient, _ := NewDeploymentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCommitmentPlansClient() *CommitmentPlansClient { + subClient, _ := NewCommitmentPlansClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go index 7ff7accc5c4d..f29c10adc801 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // CommitmentPlansClient contains the methods for the CommitmentPlans group. // Don't use this type directly, use NewCommitmentPlansClient() instead. type CommitmentPlansClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCommitmentPlansClient creates a new instance of CommitmentPlansClient with the specified values. @@ -36,21 +33,13 @@ type CommitmentPlansClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCommitmentPlansClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CommitmentPlansClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CommitmentPlansClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CommitmentPlansClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *CommitmentPlansClient) CreateOrUpdate(ctx context.Context, resourc if err != nil { return CommitmentPlansClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientCreateOrUpdateResponse{}, err } @@ -99,7 +88,7 @@ func (client *CommitmentPlansClient) createOrUpdateCreateRequest(ctx context.Con return nil, errors.New("parameter commitmentPlanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{commitmentPlanName}", url.PathEscape(commitmentPlanName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -135,11 +124,11 @@ func (client *CommitmentPlansClient) BeginCreateOrUpdateAssociation(ctx context. if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommitmentPlansClientCreateOrUpdateAssociationResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommitmentPlansClientCreateOrUpdateAssociationResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CommitmentPlansClientCreateOrUpdateAssociationResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CommitmentPlansClientCreateOrUpdateAssociationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -152,7 +141,7 @@ func (client *CommitmentPlansClient) createOrUpdateAssociation(ctx context.Conte if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -181,7 +170,7 @@ func (client *CommitmentPlansClient) createOrUpdateAssociationCreateRequest(ctx return nil, errors.New("parameter commitmentPlanAssociationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{commitmentPlanAssociationName}", url.PathEscape(commitmentPlanAssociationName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -207,11 +196,11 @@ func (client *CommitmentPlansClient) BeginCreateOrUpdatePlan(ctx context.Context if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommitmentPlansClientCreateOrUpdatePlanResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommitmentPlansClientCreateOrUpdatePlanResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CommitmentPlansClientCreateOrUpdatePlanResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CommitmentPlansClientCreateOrUpdatePlanResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -224,7 +213,7 @@ func (client *CommitmentPlansClient) createOrUpdatePlan(ctx context.Context, res if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -249,7 +238,7 @@ func (client *CommitmentPlansClient) createOrUpdatePlanCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -275,9 +264,9 @@ func (client *CommitmentPlansClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller[CommitmentPlansClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[CommitmentPlansClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CommitmentPlansClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CommitmentPlansClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -290,7 +279,7 @@ func (client *CommitmentPlansClient) deleteOperation(ctx context.Context, resour if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -319,7 +308,7 @@ func (client *CommitmentPlansClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter commitmentPlanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{commitmentPlanName}", url.PathEscape(commitmentPlanName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -345,11 +334,11 @@ func (client *CommitmentPlansClient) BeginDeleteAssociation(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommitmentPlansClientDeleteAssociationResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommitmentPlansClientDeleteAssociationResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[CommitmentPlansClientDeleteAssociationResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CommitmentPlansClientDeleteAssociationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -362,7 +351,7 @@ func (client *CommitmentPlansClient) deleteAssociation(ctx context.Context, reso if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -391,7 +380,7 @@ func (client *CommitmentPlansClient) deleteAssociationCreateRequest(ctx context. return nil, errors.New("parameter commitmentPlanAssociationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{commitmentPlanAssociationName}", url.PathEscape(commitmentPlanAssociationName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -416,11 +405,11 @@ func (client *CommitmentPlansClient) BeginDeletePlan(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommitmentPlansClientDeletePlanResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommitmentPlansClientDeletePlanResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[CommitmentPlansClientDeletePlanResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CommitmentPlansClientDeletePlanResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -433,7 +422,7 @@ func (client *CommitmentPlansClient) deletePlan(ctx context.Context, resourceGro if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -458,7 +447,7 @@ func (client *CommitmentPlansClient) deletePlanCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -482,7 +471,7 @@ func (client *CommitmentPlansClient) Get(ctx context.Context, resourceGroupName if err != nil { return CommitmentPlansClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientGetResponse{}, err } @@ -511,7 +500,7 @@ func (client *CommitmentPlansClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter commitmentPlanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{commitmentPlanName}", url.PathEscape(commitmentPlanName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -545,7 +534,7 @@ func (client *CommitmentPlansClient) GetAssociation(ctx context.Context, resourc if err != nil { return CommitmentPlansClientGetAssociationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientGetAssociationResponse{}, err } @@ -574,7 +563,7 @@ func (client *CommitmentPlansClient) getAssociationCreateRequest(ctx context.Con return nil, errors.New("parameter commitmentPlanAssociationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{commitmentPlanAssociationName}", url.PathEscape(commitmentPlanAssociationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -606,7 +595,7 @@ func (client *CommitmentPlansClient) GetPlan(ctx context.Context, resourceGroupN if err != nil { return CommitmentPlansClientGetPlanResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientGetPlanResponse{}, err } @@ -631,7 +620,7 @@ func (client *CommitmentPlansClient) getPlanCreateRequest(ctx context.Context, r return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -674,7 +663,7 @@ func (client *CommitmentPlansClient) NewListPager(resourceGroupName string, acco if err != nil { return CommitmentPlansClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientListResponse{}, err } @@ -701,7 +690,7 @@ func (client *CommitmentPlansClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -744,7 +733,7 @@ func (client *CommitmentPlansClient) NewListAssociationsPager(resourceGroupName if err != nil { return CommitmentPlansClientListAssociationsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientListAssociationsResponse{}, err } @@ -771,7 +760,7 @@ func (client *CommitmentPlansClient) listAssociationsCreateRequest(ctx context.C return nil, errors.New("parameter commitmentPlanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{commitmentPlanName}", url.PathEscape(commitmentPlanName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -813,7 +802,7 @@ func (client *CommitmentPlansClient) NewListPlansByResourceGroupPager(resourceGr if err != nil { return CommitmentPlansClientListPlansByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientListPlansByResourceGroupResponse{}, err } @@ -836,7 +825,7 @@ func (client *CommitmentPlansClient) listPlansByResourceGroupCreateRequest(ctx c return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -877,7 +866,7 @@ func (client *CommitmentPlansClient) NewListPlansBySubscriptionPager(options *Co if err != nil { return CommitmentPlansClientListPlansBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentPlansClientListPlansBySubscriptionResponse{}, err } @@ -896,7 +885,7 @@ func (client *CommitmentPlansClient) listPlansBySubscriptionCreateRequest(ctx co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -931,11 +920,11 @@ func (client *CommitmentPlansClient) BeginUpdatePlan(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommitmentPlansClientUpdatePlanResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommitmentPlansClientUpdatePlanResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[CommitmentPlansClientUpdatePlanResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CommitmentPlansClientUpdatePlanResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -948,7 +937,7 @@ func (client *CommitmentPlansClient) updatePlan(ctx context.Context, resourceGro if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -973,7 +962,7 @@ func (client *CommitmentPlansClient) updatePlanCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go index 1607fa5e02b8..2a4bb074bce3 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go @@ -25,11 +25,11 @@ func ExampleCommitmentPlansClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("resourceGroupName", "accountName", nil) + pager := clientFactory.NewCommitmentPlansClient().NewListPager("resourceGroupName", "accountName", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -66,11 +66,11 @@ func ExampleCommitmentPlansClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroupName", "accountName", "commitmentPlanName", nil) + res, err := clientFactory.NewCommitmentPlansClient().Get(ctx, "resourceGroupName", "accountName", "commitmentPlanName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -99,11 +99,11 @@ func ExampleCommitmentPlansClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "resourceGroupName", "accountName", "commitmentPlanName", armcognitiveservices.CommitmentPlan{ + res, err := clientFactory.NewCommitmentPlansClient().CreateOrUpdate(ctx, "resourceGroupName", "accountName", "commitmentPlanName", armcognitiveservices.CommitmentPlan{ Properties: &armcognitiveservices.CommitmentPlanProperties{ AutoRenew: to.Ptr(true), Current: &armcognitiveservices.CommitmentPeriod{ @@ -141,11 +141,11 @@ func ExampleCommitmentPlansClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "resourceGroupName", "accountName", "commitmentPlanName", nil) + poller, err := clientFactory.NewCommitmentPlansClient().BeginDelete(ctx, "resourceGroupName", "accountName", "commitmentPlanName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -162,11 +162,11 @@ func ExampleCommitmentPlansClient_BeginCreateOrUpdatePlan() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdatePlan(ctx, "resourceGroupName", "commitmentPlanName", armcognitiveservices.CommitmentPlan{ + poller, err := clientFactory.NewCommitmentPlansClient().BeginCreateOrUpdatePlan(ctx, "resourceGroupName", "commitmentPlanName", armcognitiveservices.CommitmentPlan{ Kind: to.Ptr("SpeechServices"), Location: to.Ptr("West US"), Properties: &armcognitiveservices.CommitmentPlanProperties{ @@ -219,11 +219,11 @@ func ExampleCommitmentPlansClient_BeginUpdatePlan() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdatePlan(ctx, "resourceGroupName", "commitmentPlanName", armcognitiveservices.PatchResourceTagsAndSKU{ + poller, err := clientFactory.NewCommitmentPlansClient().BeginUpdatePlan(ctx, "resourceGroupName", "commitmentPlanName", armcognitiveservices.PatchResourceTagsAndSKU{ Tags: map[string]*string{ "name": to.Ptr("value"), }, @@ -269,11 +269,11 @@ func ExampleCommitmentPlansClient_BeginDeletePlan() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDeletePlan(ctx, "resourceGroupName", "commitmentPlanName", nil) + poller, err := clientFactory.NewCommitmentPlansClient().BeginDeletePlan(ctx, "resourceGroupName", "commitmentPlanName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -290,11 +290,11 @@ func ExampleCommitmentPlansClient_GetPlan() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetPlan(ctx, "resourceGroupName", "commitmentPlanName", nil) + res, err := clientFactory.NewCommitmentPlansClient().GetPlan(ctx, "resourceGroupName", "commitmentPlanName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -329,11 +329,11 @@ func ExampleCommitmentPlansClient_NewListPlansByResourceGroupPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPlansByResourceGroupPager("resourceGroupName", nil) + pager := clientFactory.NewCommitmentPlansClient().NewListPlansByResourceGroupPager("resourceGroupName", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -376,11 +376,11 @@ func ExampleCommitmentPlansClient_NewListPlansBySubscriptionPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPlansBySubscriptionPager(nil) + pager := clientFactory.NewCommitmentPlansClient().NewListPlansBySubscriptionPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -423,11 +423,11 @@ func ExampleCommitmentPlansClient_NewListAssociationsPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListAssociationsPager("resourceGroupName", "commitmentPlanName", nil) + pager := clientFactory.NewCommitmentPlansClient().NewListAssociationsPager("resourceGroupName", "commitmentPlanName", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -459,11 +459,11 @@ func ExampleCommitmentPlansClient_GetAssociation() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetAssociation(ctx, "resourceGroupName", "commitmentPlanName", "commitmentPlanAssociationName", nil) + res, err := clientFactory.NewCommitmentPlansClient().GetAssociation(ctx, "resourceGroupName", "commitmentPlanName", "commitmentPlanAssociationName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -487,11 +487,11 @@ func ExampleCommitmentPlansClient_BeginCreateOrUpdateAssociation() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdateAssociation(ctx, "resourceGroupName", "commitmentPlanName", "commitmentPlanAssociationName", armcognitiveservices.CommitmentPlanAccountAssociation{ + poller, err := clientFactory.NewCommitmentPlansClient().BeginCreateOrUpdateAssociation(ctx, "resourceGroupName", "commitmentPlanName", "commitmentPlanAssociationName", armcognitiveservices.CommitmentPlanAccountAssociation{ Properties: &armcognitiveservices.CommitmentPlanAccountAssociationProperties{ AccountID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName"), }, @@ -523,11 +523,11 @@ func ExampleCommitmentPlansClient_BeginDeleteAssociation() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentPlansClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDeleteAssociation(ctx, "resourceGroupName", "commitmentPlanName", "commitmentPlanAssociationName", nil) + poller, err := clientFactory.NewCommitmentPlansClient().BeginDeleteAssociation(ctx, "resourceGroupName", "commitmentPlanName", "commitmentPlanAssociationName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go index d56a1fd00063..ca87db87cdf5 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // CommitmentTiersClient contains the methods for the CommitmentTiers group. // Don't use this type directly, use NewCommitmentTiersClient() instead. type CommitmentTiersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCommitmentTiersClient creates a new instance of CommitmentTiersClient with the specified values. @@ -36,21 +33,13 @@ type CommitmentTiersClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCommitmentTiersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CommitmentTiersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CommitmentTiersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CommitmentTiersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -77,7 +66,7 @@ func (client *CommitmentTiersClient) NewListPager(location string, options *Comm if err != nil { return CommitmentTiersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommitmentTiersClientListResponse{}, err } @@ -100,7 +89,7 @@ func (client *CommitmentTiersClient) listCreateRequest(ctx context.Context, loca return nil, errors.New("parameter location cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go index b4a6811e21d5..eebcb7837432 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go @@ -24,11 +24,11 @@ func ExampleCommitmentTiersClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewCommitmentTiersClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("location", nil) + pager := clientFactory.NewCommitmentTiersClient().NewListPager("location", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go index ee71c910310f..5745b2f09a95 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go @@ -11,7 +11,7 @@ package armcognitiveservices const ( moduleName = "armcognitiveservices" - moduleVersion = "v1.3.0" + moduleVersion = "v1.4.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go index 7e954d941a5b..968c42dcc038 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // DeletedAccountsClient contains the methods for the DeletedAccounts group. // Don't use this type directly, use NewDeletedAccountsClient() instead. type DeletedAccountsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDeletedAccountsClient creates a new instance of DeletedAccountsClient with the specified values. @@ -36,21 +33,13 @@ type DeletedAccountsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDeletedAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeletedAccountsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DeletedAccountsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DeletedAccountsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -68,7 +57,7 @@ func (client *DeletedAccountsClient) Get(ctx context.Context, location string, r if err != nil { return DeletedAccountsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeletedAccountsClientGetResponse{}, err } @@ -97,7 +86,7 @@ func (client *DeletedAccountsClient) getCreateRequest(ctx context.Context, locat return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -138,7 +127,7 @@ func (client *DeletedAccountsClient) NewListPager(options *DeletedAccountsClient if err != nil { return DeletedAccountsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeletedAccountsClientListResponse{}, err } @@ -157,7 +146,7 @@ func (client *DeletedAccountsClient) listCreateRequest(ctx context.Context, opti return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -192,9 +181,9 @@ func (client *DeletedAccountsClient) BeginPurge(ctx context.Context, location st if err != nil { return nil, err } - return runtime.NewPoller[DeletedAccountsClientPurgeResponse](resp, client.pl, nil) + return runtime.NewPoller[DeletedAccountsClientPurgeResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DeletedAccountsClientPurgeResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DeletedAccountsClientPurgeResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -207,7 +196,7 @@ func (client *DeletedAccountsClient) purge(ctx context.Context, location string, if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -236,7 +225,7 @@ func (client *DeletedAccountsClient) purgeCreateRequest(ctx context.Context, loc return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go index 445a4e233f02..8f4c80194797 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go @@ -24,11 +24,11 @@ func ExampleDeletedAccountsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewDeletedAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "westus", "myResourceGroup", "myAccount", nil) + res, err := clientFactory.NewDeletedAccountsClient().Get(ctx, "westus", "myResourceGroup", "myAccount", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -63,11 +63,11 @@ func ExampleDeletedAccountsClient_BeginPurge() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewDeletedAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginPurge(ctx, "westus", "myResourceGroup", "PropTest01", nil) + poller, err := clientFactory.NewDeletedAccountsClient().BeginPurge(ctx, "westus", "myResourceGroup", "PropTest01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -84,11 +84,11 @@ func ExampleDeletedAccountsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewDeletedAccountsClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewDeletedAccountsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go index fa4d75f7ed28..41812582d467 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // DeploymentsClient contains the methods for the Deployments group. // Don't use this type directly, use NewDeploymentsClient() instead. type DeploymentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDeploymentsClient creates a new instance of DeploymentsClient with the specified values. @@ -36,21 +33,13 @@ type DeploymentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DeploymentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DeploymentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller[DeploymentsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DeploymentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DeploymentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DeploymentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGro if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +104,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -140,9 +129,9 @@ func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupN if err != nil { return nil, err } - return runtime.NewPoller[DeploymentsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DeploymentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DeploymentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DeploymentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -155,7 +144,7 @@ func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGr if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -184,7 +173,7 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -208,7 +197,7 @@ func (client *DeploymentsClient) Get(ctx context.Context, resourceGroupName stri if err != nil { return DeploymentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeploymentsClientGetResponse{}, err } @@ -237,7 +226,7 @@ func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter deploymentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -279,7 +268,7 @@ func (client *DeploymentsClient) NewListPager(resourceGroupName string, accountN if err != nil { return DeploymentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeploymentsClientListResponse{}, err } @@ -306,7 +295,7 @@ func (client *DeploymentsClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go index e3b3d6df0c87..eb195ef93314 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go @@ -25,11 +25,11 @@ func ExampleDeploymentsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewDeploymentsClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("resourceGroupName", "accountName", nil) + pager := clientFactory.NewDeploymentsClient().NewListPager("resourceGroupName", "accountName", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -70,11 +70,11 @@ func ExampleDeploymentsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewDeploymentsClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroupName", "accountName", "deploymentName", nil) + res, err := clientFactory.NewDeploymentsClient().Get(ctx, "resourceGroupName", "accountName", "deploymentName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -107,11 +107,11 @@ func ExampleDeploymentsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewDeploymentsClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "resourceGroupName", "accountName", "deploymentName", armcognitiveservices.Deployment{ + poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "resourceGroupName", "accountName", "deploymentName", armcognitiveservices.Deployment{ Properties: &armcognitiveservices.DeploymentProperties{ Model: &armcognitiveservices.DeploymentModel{ Name: to.Ptr("ada"), @@ -160,11 +160,11 @@ func ExampleDeploymentsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewDeploymentsClient("subscriptionId", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "resourceGroupName", "accountName", "deploymentName", nil) + poller, err := clientFactory.NewDeploymentsClient().BeginDelete(ctx, "resourceGroupName", "accountName", "deploymentName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.mod b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.mod index a6692090d9db..b30190bce877 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.mod +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/a go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.sum b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.sum index 67cfef6bdf6e..8ba445a8c4da 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.sum +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/go.sum @@ -1,30 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go index 4cbca4aaf373..96e8e3e4c428 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // ManagementClient contains the methods for the CognitiveServicesManagementClient group. // Don't use this type directly, use NewManagementClient() instead. type ManagementClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewManagementClient creates a new instance of ManagementClient with the specified values. @@ -36,21 +33,13 @@ type ManagementClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewManagementClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagementClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ManagementClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ManagementClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -67,7 +56,7 @@ func (client *ManagementClient) CheckDomainAvailability(ctx context.Context, par if err != nil { return ManagementClientCheckDomainAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientCheckDomainAvailabilityResponse{}, err } @@ -84,7 +73,7 @@ func (client *ManagementClient) checkDomainAvailabilityCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,7 +106,7 @@ func (client *ManagementClient) CheckSKUAvailability(ctx context.Context, locati if err != nil { return ManagementClientCheckSKUAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientCheckSKUAvailabilityResponse{}, err } @@ -138,7 +127,7 @@ func (client *ManagementClient) checkSKUAvailabilityCreateRequest(ctx context.Co return nil, errors.New("parameter location cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go index 756497d21535..7e9af7970ad5 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go @@ -25,11 +25,11 @@ func ExampleManagementClient_CheckSKUAvailability() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewManagementClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckSKUAvailability(ctx, "westus", armcognitiveservices.CheckSKUAvailabilityParameter{ + res, err := clientFactory.NewManagementClient().CheckSKUAvailability(ctx, "westus", armcognitiveservices.CheckSKUAvailabilityParameter{ Type: to.Ptr("Microsoft.CognitiveServices/accounts"), Kind: to.Ptr("Face"), SKUs: []*string{ @@ -59,11 +59,11 @@ func ExampleManagementClient_CheckDomainAvailability() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewManagementClient("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckDomainAvailability(ctx, armcognitiveservices.CheckDomainAvailabilityParameter{ + res, err := clientFactory.NewManagementClient().CheckDomainAvailability(ctx, armcognitiveservices.CheckDomainAvailabilityParameter{ Type: to.Ptr("Microsoft.CognitiveServices/accounts"), SubdomainName: to.Ptr("contosodemoapp1"), }, nil) diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go index c07950a2eae2..fa54a9d9cf60 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,28 +21,19 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -84,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CognitiveServices/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go index 3ef5511ad2c1..569054c8fcfe 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go @@ -24,11 +24,11 @@ func ExampleOperationsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewOperationsClient(cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go index e091478b171a..ae83b0b15d57 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. // Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. type PrivateEndpointConnectionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. @@ -36,21 +33,13 @@ type PrivateEndpointConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateEndpointConnectionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,9 +61,9 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[PrivateEndpointConnectionsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Conte if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -116,7 +105,7 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -142,9 +131,9 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -157,7 +146,7 @@ func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Cont if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -186,7 +175,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -211,7 +200,7 @@ func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourc if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } @@ -240,7 +229,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -273,7 +262,7 @@ func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resour if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } @@ -298,7 +287,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go index 31dd27d68148..dd8a8179c2e6 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go @@ -25,11 +25,11 @@ func ExamplePrivateEndpointConnectionsClient_List() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "res6977", "sto2527", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().List(ctx, "res6977", "sto2527", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -63,11 +63,11 @@ func ExamplePrivateEndpointConnectionsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -98,11 +98,11 @@ func ExamplePrivateEndpointConnectionsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", armcognitiveservices.PrivateEndpointConnection{ + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginCreateOrUpdate(ctx, "res7687", "sto9699", "{privateEndpointConnectionName}", armcognitiveservices.PrivateEndpointConnection{ Properties: &armcognitiveservices.PrivateEndpointConnectionProperties{ PrivateLinkServiceConnectionState: &armcognitiveservices.PrivateLinkServiceConnectionState{ Description: to.Ptr("Auto-Approved"), @@ -144,11 +144,11 @@ func ExamplePrivateEndpointConnectionsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewPrivateEndpointConnectionsClient("{subscription-id}", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginDelete(ctx, "res6977", "sto2527", "{privateEndpointConnectionName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go index a5f4b3172a74..767c60d038d0 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. // Don't use this type directly, use NewPrivateLinkResourcesClient() instead. type PrivateLinkResourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. @@ -36,21 +33,13 @@ type PrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateLinkResourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -68,7 +57,7 @@ func (client *PrivateLinkResourcesClient) List(ctx context.Context, resourceGrou if err != nil { return PrivateLinkResourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientListResponse{}, err } @@ -93,7 +82,7 @@ func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go index 2c6e317431cc..9059358465a5 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go @@ -24,11 +24,11 @@ func ExamplePrivateLinkResourcesClient_List() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewPrivateLinkResourcesClient("{subscription-id}", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "res6977", "sto2527", nil) + res, err := clientFactory.NewPrivateLinkResourcesClient().List(ctx, "res6977", "sto2527", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client.go index dffab6fc46a5..e4db8126b6a9 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // ResourceSKUsClient contains the methods for the ResourceSKUs group. // Don't use this type directly, use NewResourceSKUsClient() instead. type ResourceSKUsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewResourceSKUsClient creates a new instance of ResourceSKUsClient with the specified values. @@ -36,21 +33,13 @@ type ResourceSKUsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewResourceSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceSKUsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ResourceSKUsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourceSKUsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -75,7 +64,7 @@ func (client *ResourceSKUsClient) NewListPager(options *ResourceSKUsClientListOp if err != nil { return ResourceSKUsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceSKUsClientListResponse{}, err } @@ -94,7 +83,7 @@ func (client *ResourceSKUsClient) listCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go index 521ed7388959..1832799ba7d6 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go @@ -24,11 +24,11 @@ func ExampleResourceSKUsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armcognitiveservices.NewResourceSKUsClient("f1c637e4-72ec-4f89-8d2b-0f933c036002", cred, nil) + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewResourceSKUsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/commerce/armcommerce/CHANGELOG.md b/sdk/resourcemanager/commerce/armcommerce/CHANGELOG.md index 653b0fb8f81b..6eb19fbf95e0 100644 --- a/sdk/resourcemanager/commerce/armcommerce/CHANGELOG.md +++ b/sdk/resourcemanager/commerce/armcommerce/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.2.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.1.0 (2022-06-10) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/commerce/armcommerce` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.1.0, which contains breaking changes. diff --git a/sdk/resourcemanager/commerce/armcommerce/README.md b/sdk/resourcemanager/commerce/armcommerce/README.md index 61fa9512ce82..a11c8ab1ad8b 100644 --- a/sdk/resourcemanager/commerce/armcommerce/README.md +++ b/sdk/resourcemanager/commerce/armcommerce/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Commerce modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Commerce module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armcommerce.NewUsageAggregatesClient(, cred, nil) +clientFactory, err := armcommerce.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armcommerce.NewUsageAggregatesClient(, cred, &options) +clientFactory, err := armcommerce.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewRateCardClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/commerce/armcommerce/autorest.md b/sdk/resourcemanager/commerce/armcommerce/autorest.md index cd14bcd541e7..d0fde16e64aa 100644 --- a/sdk/resourcemanager/commerce/armcommerce/autorest.md +++ b/sdk/resourcemanager/commerce/armcommerce/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/commerce/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/commerce/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 +module-version: 0.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/commerce/armcommerce/client_factory.go b/sdk/resourcemanager/commerce/armcommerce/client_factory.go new file mode 100644 index 000000000000..26e69df09200 --- /dev/null +++ b/sdk/resourcemanager/commerce/armcommerce/client_factory.go @@ -0,0 +1,50 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armcommerce + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every +// service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewUsageAggregatesClient() *UsageAggregatesClient { + subClient, _ := NewUsageAggregatesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRateCardClient() *RateCardClient { + subClient, _ := NewRateCardClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_constants.go b/sdk/resourcemanager/commerce/armcommerce/constants.go similarity index 97% rename from sdk/resourcemanager/commerce/armcommerce/zz_generated_constants.go rename to sdk/resourcemanager/commerce/armcommerce/constants.go index e1f35c39754c..f46a1c027b08 100644 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_constants.go +++ b/sdk/resourcemanager/commerce/armcommerce/constants.go @@ -5,12 +5,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armcommerce const ( moduleName = "armcommerce" - moduleVersion = "v0.1.0" + moduleVersion = "v0.2.0" ) type AggregationGranularity string diff --git a/sdk/resourcemanager/commerce/armcommerce/go.mod b/sdk/resourcemanager/commerce/armcommerce/go.mod index 0bdae7ae92d7..ed023affbe11 100644 --- a/sdk/resourcemanager/commerce/armcommerce/go.mod +++ b/sdk/resourcemanager/commerce/armcommerce/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/commerce/armcommerc go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/commerce/armcommerce/go.sum b/sdk/resourcemanager/commerce/armcommerce/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/commerce/armcommerce/go.sum +++ b/sdk/resourcemanager/commerce/armcommerce/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_models.go b/sdk/resourcemanager/commerce/armcommerce/models.go similarity index 99% rename from sdk/resourcemanager/commerce/armcommerce/zz_generated_models.go rename to sdk/resourcemanager/commerce/armcommerce/models.go index 80358ce193d8..8afab235ecc7 100644 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_models.go +++ b/sdk/resourcemanager/commerce/armcommerce/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armcommerce @@ -190,7 +191,7 @@ type ResourceRateCardInfo struct { OfferTerms []OfferTermInfoAutoGeneratedClassification `json:"OfferTerms,omitempty"` } -// UsageAggregatesClientListOptions contains the optional parameters for the UsageAggregatesClient.List method. +// UsageAggregatesClientListOptions contains the optional parameters for the UsageAggregatesClient.NewListPager method. type UsageAggregatesClientListOptions struct { // Daily (default) returns the data in daily granularity, Hourly returns the data in hourly granularity. AggregationGranularity *AggregationGranularity diff --git a/sdk/resourcemanager/commerce/armcommerce/models_serde.go b/sdk/resourcemanager/commerce/armcommerce/models_serde.go new file mode 100644 index 000000000000..c4c1a85465c7 --- /dev/null +++ b/sdk/resourcemanager/commerce/armcommerce/models_serde.go @@ -0,0 +1,525 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armcommerce + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InfoField. +func (i InfoField) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "project", i.Project) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfoField. +func (i *InfoField) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "project": + err = unpopulate(val, "Project", &i.Project) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MeterInfo. +func (m MeterInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "EffectiveDate", m.EffectiveDate) + populate(objectMap, "IncludedQuantity", m.IncludedQuantity) + populate(objectMap, "MeterCategory", m.MeterCategory) + populate(objectMap, "MeterId", m.MeterID) + populate(objectMap, "MeterName", m.MeterName) + populate(objectMap, "MeterRates", m.MeterRates) + populate(objectMap, "MeterRegion", m.MeterRegion) + populate(objectMap, "MeterSubCategory", m.MeterSubCategory) + populate(objectMap, "MeterTags", m.MeterTags) + populate(objectMap, "Unit", m.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MeterInfo. +func (m *MeterInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EffectiveDate": + err = unpopulateTimeRFC3339(val, "EffectiveDate", &m.EffectiveDate) + delete(rawMsg, key) + case "IncludedQuantity": + err = unpopulate(val, "IncludedQuantity", &m.IncludedQuantity) + delete(rawMsg, key) + case "MeterCategory": + err = unpopulate(val, "MeterCategory", &m.MeterCategory) + delete(rawMsg, key) + case "MeterId": + err = unpopulate(val, "MeterID", &m.MeterID) + delete(rawMsg, key) + case "MeterName": + err = unpopulate(val, "MeterName", &m.MeterName) + delete(rawMsg, key) + case "MeterRates": + err = unpopulate(val, "MeterRates", &m.MeterRates) + delete(rawMsg, key) + case "MeterRegion": + err = unpopulate(val, "MeterRegion", &m.MeterRegion) + delete(rawMsg, key) + case "MeterSubCategory": + err = unpopulate(val, "MeterSubCategory", &m.MeterSubCategory) + delete(rawMsg, key) + case "MeterTags": + err = unpopulate(val, "MeterTags", &m.MeterTags) + delete(rawMsg, key) + case "Unit": + err = unpopulate(val, "Unit", &m.Unit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonetaryCommitment. +func (m MonetaryCommitment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "EffectiveDate", m.EffectiveDate) + populate(objectMap, "ExcludedMeterIds", m.ExcludedMeterIDs) + objectMap["Name"] = OfferTermInfoMonetaryCommitment + populate(objectMap, "TieredDiscount", m.TieredDiscount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonetaryCommitment. +func (m *MonetaryCommitment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EffectiveDate": + err = unpopulateTimeRFC3339(val, "EffectiveDate", &m.EffectiveDate) + delete(rawMsg, key) + case "ExcludedMeterIds": + err = unpopulate(val, "ExcludedMeterIDs", &m.ExcludedMeterIDs) + delete(rawMsg, key) + case "Name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "TieredDiscount": + err = unpopulate(val, "TieredDiscount", &m.TieredDiscount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonetaryCredit. +func (m MonetaryCredit) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "Credit", m.Credit) + populateTimeRFC3339(objectMap, "EffectiveDate", m.EffectiveDate) + populate(objectMap, "ExcludedMeterIds", m.ExcludedMeterIDs) + objectMap["Name"] = OfferTermInfoMonetaryCredit + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonetaryCredit. +func (m *MonetaryCredit) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "Credit": + err = unpopulate(val, "Credit", &m.Credit) + delete(rawMsg, key) + case "EffectiveDate": + err = unpopulateTimeRFC3339(val, "EffectiveDate", &m.EffectiveDate) + delete(rawMsg, key) + case "ExcludedMeterIds": + err = unpopulate(val, "ExcludedMeterIDs", &m.ExcludedMeterIDs) + delete(rawMsg, key) + case "Name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OfferTermInfoAutoGenerated. +func (o OfferTermInfoAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "EffectiveDate", o.EffectiveDate) + objectMap["Name"] = o.Name + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OfferTermInfoAutoGenerated. +func (o *OfferTermInfoAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EffectiveDate": + err = unpopulateTimeRFC3339(val, "EffectiveDate", &o.EffectiveDate) + delete(rawMsg, key) + case "Name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RateCardQueryParameters. +func (r RateCardQueryParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "Currency", r.Currency) + populate(objectMap, "Locale", r.Locale) + populate(objectMap, "OfferDurableId", r.OfferDurableID) + populate(objectMap, "RegionInfo", r.RegionInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RateCardQueryParameters. +func (r *RateCardQueryParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "Currency": + err = unpopulate(val, "Currency", &r.Currency) + delete(rawMsg, key) + case "Locale": + err = unpopulate(val, "Locale", &r.Locale) + delete(rawMsg, key) + case "OfferDurableId": + err = unpopulate(val, "OfferDurableID", &r.OfferDurableID) + delete(rawMsg, key) + case "RegionInfo": + err = unpopulate(val, "RegionInfo", &r.RegionInfo) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecurringCharge. +func (r RecurringCharge) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "EffectiveDate", r.EffectiveDate) + objectMap["Name"] = OfferTermInfoRecurringCharge + populate(objectMap, "RecurringCharge", r.RecurringCharge) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecurringCharge. +func (r *RecurringCharge) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "EffectiveDate": + err = unpopulateTimeRFC3339(val, "EffectiveDate", &r.EffectiveDate) + delete(rawMsg, key) + case "Name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "RecurringCharge": + err = unpopulate(val, "RecurringCharge", &r.RecurringCharge) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceRateCardInfo. +func (r ResourceRateCardInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "Currency", r.Currency) + populate(objectMap, "IsTaxIncluded", r.IsTaxIncluded) + populate(objectMap, "Locale", r.Locale) + populate(objectMap, "Meters", r.Meters) + populate(objectMap, "OfferTerms", r.OfferTerms) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceRateCardInfo. +func (r *ResourceRateCardInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "Currency": + err = unpopulate(val, "Currency", &r.Currency) + delete(rawMsg, key) + case "IsTaxIncluded": + err = unpopulate(val, "IsTaxIncluded", &r.IsTaxIncluded) + delete(rawMsg, key) + case "Locale": + err = unpopulate(val, "Locale", &r.Locale) + delete(rawMsg, key) + case "Meters": + err = unpopulate(val, "Meters", &r.Meters) + delete(rawMsg, key) + case "OfferTerms": + r.OfferTerms, err = unmarshalOfferTermInfoAutoGeneratedClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UsageAggregation. +func (u UsageAggregation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", u.ID) + populate(objectMap, "name", u.Name) + populate(objectMap, "properties", u.Properties) + populate(objectMap, "type", u.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UsageAggregation. +func (u *UsageAggregation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &u.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &u.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &u.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UsageAggregationListResult. +func (u UsageAggregationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", u.NextLink) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UsageAggregationListResult. +func (u *UsageAggregationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &u.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &u.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UsageSample. +func (u UsageSample) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "infoFields", u.InfoFields) + populate(objectMap, "instanceData", u.InstanceData) + populate(objectMap, "meterCategory", u.MeterCategory) + populate(objectMap, "meterId", u.MeterID) + populate(objectMap, "meterName", u.MeterName) + populate(objectMap, "meterRegion", u.MeterRegion) + populate(objectMap, "meterSubCategory", u.MeterSubCategory) + populate(objectMap, "quantity", u.Quantity) + populate(objectMap, "subscriptionId", u.SubscriptionID) + populate(objectMap, "unit", u.Unit) + populateTimeRFC3339(objectMap, "usageEndTime", u.UsageEndTime) + populateTimeRFC3339(objectMap, "usageStartTime", u.UsageStartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UsageSample. +func (u *UsageSample) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "infoFields": + err = unpopulate(val, "InfoFields", &u.InfoFields) + delete(rawMsg, key) + case "instanceData": + err = unpopulate(val, "InstanceData", &u.InstanceData) + delete(rawMsg, key) + case "meterCategory": + err = unpopulate(val, "MeterCategory", &u.MeterCategory) + delete(rawMsg, key) + case "meterId": + err = unpopulate(val, "MeterID", &u.MeterID) + delete(rawMsg, key) + case "meterName": + err = unpopulate(val, "MeterName", &u.MeterName) + delete(rawMsg, key) + case "meterRegion": + err = unpopulate(val, "MeterRegion", &u.MeterRegion) + delete(rawMsg, key) + case "meterSubCategory": + err = unpopulate(val, "MeterSubCategory", &u.MeterSubCategory) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &u.Quantity) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &u.SubscriptionID) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &u.Unit) + delete(rawMsg, key) + case "usageEndTime": + err = unpopulateTimeRFC3339(val, "UsageEndTime", &u.UsageEndTime) + delete(rawMsg, key) + case "usageStartTime": + err = unpopulateTimeRFC3339(val, "UsageStartTime", &u.UsageStartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/commerce/armcommerce/polymorphic_helpers.go similarity index 97% rename from sdk/resourcemanager/commerce/armcommerce/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/commerce/armcommerce/polymorphic_helpers.go index 56ec2f130d98..90a20987874b 100644 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/commerce/armcommerce/polymorphic_helpers.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armcommerce @@ -14,7 +15,7 @@ func unmarshalOfferTermInfoAutoGeneratedClassification(rawMsg json.RawMessage) ( if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_ratecard_client.go b/sdk/resourcemanager/commerce/armcommerce/ratecard_client.go similarity index 74% rename from sdk/resourcemanager/commerce/armcommerce/zz_generated_ratecard_client.go rename to sdk/resourcemanager/commerce/armcommerce/ratecard_client.go index 8e18e249940f..ba9327daba52 100644 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_ratecard_client.go +++ b/sdk/resourcemanager/commerce/armcommerce/ratecard_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armcommerce @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,32 +24,23 @@ import ( // RateCardClient contains the methods for the RateCard group. // Don't use this type directly, use NewRateCardClient() instead. type RateCardClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRateCardClient creates a new instance of RateCardClient with the specified values. -// subscriptionID - It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every -// service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every +// service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRateCardClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RateCardClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RateCardClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RateCardClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -63,17 +53,18 @@ func NewRateCardClient(subscriptionID string, credential azcore.TokenCredential, // to change due to a new billing model, you will be notified in advance of the // change. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2015-06-01-preview -// filter - The filter to apply on the operation. It ONLY supports the 'eq' and 'and' logical operators at this time. All -// the 4 query parameters 'OfferDurableId', 'Currency', 'Locale', 'Region' are required to be -// a part of the $filter. -// options - RateCardClientGetOptions contains the optional parameters for the RateCardClient.Get method. +// - filter - The filter to apply on the operation. It ONLY supports the 'eq' and 'and' logical operators at this time. All +// the 4 query parameters 'OfferDurableId', 'Currency', 'Locale', 'Region' are required to be +// a part of the $filter. +// - options - RateCardClientGetOptions contains the optional parameters for the RateCardClient.Get method. func (client *RateCardClient) Get(ctx context.Context, filter string, options *RateCardClientGetOptions) (RateCardClientGetResponse, error) { req, err := client.getCreateRequest(ctx, filter, options) if err != nil { return RateCardClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RateCardClientGetResponse{}, err } @@ -90,7 +81,7 @@ func (client *RateCardClient) getCreateRequest(ctx context.Context, filter strin return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/commerce/armcommerce/ratecard_client_example_test.go b/sdk/resourcemanager/commerce/armcommerce/ratecard_client_example_test.go new file mode 100644 index 000000000000..afd7f0a2871f --- /dev/null +++ b/sdk/resourcemanager/commerce/armcommerce/ratecard_client_example_test.go @@ -0,0 +1,59 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armcommerce_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/commerce/armcommerce" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/commerce/resource-manager/Microsoft.Commerce/preview/2015-06-01-preview/examples/GetRateCard.json +func ExampleRateCardClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcommerce.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRateCardClient().Get(ctx, "OfferDurableId eq 'MS-AZR-0003P' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourceRateCardInfo = armcommerce.ResourceRateCardInfo{ + // Meters: []*armcommerce.MeterInfo{ + // { + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-01T00:00:00Z"); return t}()), + // IncludedQuantity: to.Ptr[float32](0), + // MeterCategory: to.Ptr("Test Category"), + // MeterID: to.Ptr("1d7518e5-bc2f-4a93-9057-1b3047856645"), + // MeterName: to.Ptr("Test Meter"), + // MeterRates: map[string]*float32{ + // "0": to.Ptr[float32](1.99), + // "100": to.Ptr[float32](0.99), + // }, + // MeterRegion: to.Ptr("US West"), + // MeterSubCategory: to.Ptr("Test Subcategory"), + // MeterTags: []*string{ + // to.Ptr("Third Party")}, + // Unit: to.Ptr("Hours"), + // }}, + // OfferTerms: []armcommerce.OfferTermInfoAutoGeneratedClassification{ + // }, + // } +} diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_response_types.go b/sdk/resourcemanager/commerce/armcommerce/response_types.go similarity index 91% rename from sdk/resourcemanager/commerce/armcommerce/zz_generated_response_types.go rename to sdk/resourcemanager/commerce/armcommerce/response_types.go index cf88d9bade58..c7ead68605ae 100644 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_response_types.go +++ b/sdk/resourcemanager/commerce/armcommerce/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armcommerce @@ -13,7 +14,7 @@ type RateCardClientGetResponse struct { ResourceRateCardInfo } -// UsageAggregatesClientListResponse contains the response from method UsageAggregatesClient.List. +// UsageAggregatesClientListResponse contains the response from method UsageAggregatesClient.NewListPager. type UsageAggregatesClientListResponse struct { UsageAggregationListResult } diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_time_rfc3339.go b/sdk/resourcemanager/commerce/armcommerce/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/commerce/armcommerce/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/commerce/armcommerce/time_rfc3339.go index 1e5619b704f7..a0a3c173ba59 100644 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/commerce/armcommerce/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armcommerce @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_usageaggregates_client.go b/sdk/resourcemanager/commerce/armcommerce/usageaggregates_client.go similarity index 78% rename from sdk/resourcemanager/commerce/armcommerce/zz_generated_usageaggregates_client.go rename to sdk/resourcemanager/commerce/armcommerce/usageaggregates_client.go index 67b137e39594..0491ef8f5f32 100644 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_usageaggregates_client.go +++ b/sdk/resourcemanager/commerce/armcommerce/usageaggregates_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armcommerce @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,42 +26,34 @@ import ( // UsageAggregatesClient contains the methods for the UsageAggregates group. // Don't use this type directly, use NewUsageAggregatesClient() instead. type UsageAggregatesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUsageAggregatesClient creates a new instance of UsageAggregatesClient with the specified values. -// subscriptionID - It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every -// service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - It uniquely identifies Microsoft Azure subscription. The subscription ID forms part of the URI for every +// service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewUsageAggregatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsageAggregatesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".UsageAggregatesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UsageAggregatesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Query aggregated Azure subscription consumption data for a date range. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2015-06-01-preview -// reportedStartTime - The start of the time range to retrieve data for. -// reportedEndTime - The end of the time range to retrieve data for. -// options - UsageAggregatesClientListOptions contains the optional parameters for the UsageAggregatesClient.List method. +// - reportedStartTime - The start of the time range to retrieve data for. +// - reportedEndTime - The end of the time range to retrieve data for. +// - options - UsageAggregatesClientListOptions contains the optional parameters for the UsageAggregatesClient.NewListPager +// method. func (client *UsageAggregatesClient) NewListPager(reportedStartTime time.Time, reportedEndTime time.Time, options *UsageAggregatesClientListOptions) *runtime.Pager[UsageAggregatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[UsageAggregatesClientListResponse]{ More: func(page UsageAggregatesClientListResponse) bool { @@ -79,7 +70,7 @@ func (client *UsageAggregatesClient) NewListPager(reportedStartTime time.Time, r if err != nil { return UsageAggregatesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UsageAggregatesClientListResponse{}, err } @@ -98,7 +89,7 @@ func (client *UsageAggregatesClient) listCreateRequest(ctx context.Context, repo return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/commerce/armcommerce/ze_generated_example_ratecard_client_test.go b/sdk/resourcemanager/commerce/armcommerce/ze_generated_example_ratecard_client_test.go deleted file mode 100644 index 8302810f4ab0..000000000000 --- a/sdk/resourcemanager/commerce/armcommerce/ze_generated_example_ratecard_client_test.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armcommerce_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/commerce/armcommerce" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/commerce/resource-manager/Microsoft.Commerce/preview/2015-06-01-preview/examples/GetRateCard.json -func ExampleRateCardClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcommerce.NewRateCardClient("6d61cc05-8f8f-4916-b1b9-f1d9c25aae27", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "OfferDurableId eq 'MS-AZR-0003P' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/commerce/armcommerce/zz_generated_models_serde.go b/sdk/resourcemanager/commerce/armcommerce/zz_generated_models_serde.go deleted file mode 100644 index e673ac594aa3..000000000000 --- a/sdk/resourcemanager/commerce/armcommerce/zz_generated_models_serde.go +++ /dev/null @@ -1,263 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armcommerce - -import ( - "encoding/json" - "fmt" -) - -// UnmarshalJSON implements the json.Unmarshaller interface for type MeterInfo. -func (m *MeterInfo) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "EffectiveDate": - err = unpopulateTimeRFC3339(val, "EffectiveDate", &m.EffectiveDate) - delete(rawMsg, key) - case "IncludedQuantity": - err = unpopulate(val, "IncludedQuantity", &m.IncludedQuantity) - delete(rawMsg, key) - case "MeterCategory": - err = unpopulate(val, "MeterCategory", &m.MeterCategory) - delete(rawMsg, key) - case "MeterId": - err = unpopulate(val, "MeterID", &m.MeterID) - delete(rawMsg, key) - case "MeterName": - err = unpopulate(val, "MeterName", &m.MeterName) - delete(rawMsg, key) - case "MeterRates": - err = unpopulate(val, "MeterRates", &m.MeterRates) - delete(rawMsg, key) - case "MeterRegion": - err = unpopulate(val, "MeterRegion", &m.MeterRegion) - delete(rawMsg, key) - case "MeterSubCategory": - err = unpopulate(val, "MeterSubCategory", &m.MeterSubCategory) - delete(rawMsg, key) - case "MeterTags": - err = unpopulate(val, "MeterTags", &m.MeterTags) - delete(rawMsg, key) - case "Unit": - err = unpopulate(val, "Unit", &m.Unit) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MonetaryCommitment. -func (m *MonetaryCommitment) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "EffectiveDate": - err = unpopulateTimeRFC3339(val, "EffectiveDate", &m.EffectiveDate) - delete(rawMsg, key) - case "ExcludedMeterIds": - err = unpopulate(val, "ExcludedMeterIDs", &m.ExcludedMeterIDs) - delete(rawMsg, key) - case "Name": - err = unpopulate(val, "Name", &m.Name) - delete(rawMsg, key) - case "TieredDiscount": - err = unpopulate(val, "TieredDiscount", &m.TieredDiscount) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MonetaryCredit. -func (m *MonetaryCredit) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "Credit": - err = unpopulate(val, "Credit", &m.Credit) - delete(rawMsg, key) - case "EffectiveDate": - err = unpopulateTimeRFC3339(val, "EffectiveDate", &m.EffectiveDate) - delete(rawMsg, key) - case "ExcludedMeterIds": - err = unpopulate(val, "ExcludedMeterIDs", &m.ExcludedMeterIDs) - delete(rawMsg, key) - case "Name": - err = unpopulate(val, "Name", &m.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OfferTermInfoAutoGenerated. -func (o *OfferTermInfoAutoGenerated) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "EffectiveDate": - err = unpopulateTimeRFC3339(val, "EffectiveDate", &o.EffectiveDate) - delete(rawMsg, key) - case "Name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RecurringCharge. -func (r *RecurringCharge) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "EffectiveDate": - err = unpopulateTimeRFC3339(val, "EffectiveDate", &r.EffectiveDate) - delete(rawMsg, key) - case "Name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "RecurringCharge": - err = unpopulate(val, "RecurringCharge", &r.RecurringCharge) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceRateCardInfo. -func (r *ResourceRateCardInfo) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "Currency": - err = unpopulate(val, "Currency", &r.Currency) - delete(rawMsg, key) - case "IsTaxIncluded": - err = unpopulate(val, "IsTaxIncluded", &r.IsTaxIncluded) - delete(rawMsg, key) - case "Locale": - err = unpopulate(val, "Locale", &r.Locale) - delete(rawMsg, key) - case "Meters": - err = unpopulate(val, "Meters", &r.Meters) - delete(rawMsg, key) - case "OfferTerms": - r.OfferTerms, err = unmarshalOfferTermInfoAutoGeneratedClassificationArray(val) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UsageSample. -func (u *UsageSample) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", u, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "infoFields": - err = unpopulate(val, "InfoFields", &u.InfoFields) - delete(rawMsg, key) - case "instanceData": - err = unpopulate(val, "InstanceData", &u.InstanceData) - delete(rawMsg, key) - case "meterCategory": - err = unpopulate(val, "MeterCategory", &u.MeterCategory) - delete(rawMsg, key) - case "meterId": - err = unpopulate(val, "MeterID", &u.MeterID) - delete(rawMsg, key) - case "meterName": - err = unpopulate(val, "MeterName", &u.MeterName) - delete(rawMsg, key) - case "meterRegion": - err = unpopulate(val, "MeterRegion", &u.MeterRegion) - delete(rawMsg, key) - case "meterSubCategory": - err = unpopulate(val, "MeterSubCategory", &u.MeterSubCategory) - delete(rawMsg, key) - case "quantity": - err = unpopulate(val, "Quantity", &u.Quantity) - delete(rawMsg, key) - case "subscriptionId": - err = unpopulate(val, "SubscriptionID", &u.SubscriptionID) - delete(rawMsg, key) - case "unit": - err = unpopulate(val, "Unit", &u.Unit) - delete(rawMsg, key) - case "usageEndTime": - err = unpopulateTimeRFC3339(val, "UsageEndTime", &u.UsageEndTime) - delete(rawMsg, key) - case "usageStartTime": - err = unpopulateTimeRFC3339(val, "UsageStartTime", &u.UsageStartTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", u, err) - } - } - return nil -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/CHANGELOG.md b/sdk/resourcemanager/confidentialledger/armconfidentialledger/CHANGELOG.md index 2544021b781e..4beac59d44c7 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/CHANGELOG.md +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-24) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confidentialledger/armconfidentialledger` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/README.md b/sdk/resourcemanager/confidentialledger/armconfidentialledger/README.md index 4431b4498ef5..8acd69819c61 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/README.md +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Confidential Ledger modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Confidential Ledger module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armconfidentialledger.NewLedgerClient(, cred, nil) +clientFactory, err := armconfidentialledger.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armconfidentialledger.NewLedgerClient(, cred, &options) +clientFactory, err := armconfidentialledger.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/autorest.md b/sdk/resourcemanager/confidentialledger/armconfidentialledger/autorest.md index e8d821d61cf6..aabf05e99691 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/autorest.md +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_client.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/client.go similarity index 75% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_client.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/client.go index 2d29769ea077..70dfd31bcb9e 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_client.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,46 +24,38 @@ import ( // Client contains the methods for the ConfidentialLedger group. // Don't use this type directly, use NewClient() instead. type Client struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewClient creates a new instance of Client with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckNameAvailability - To check whether a resource name is available. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// nameAvailabilityRequest - Name availability request payload. -// options - ClientCheckNameAvailabilityOptions contains the optional parameters for the Client.CheckNameAvailability method. +// - nameAvailabilityRequest - Name availability request payload. +// - options - ClientCheckNameAvailabilityOptions contains the optional parameters for the Client.CheckNameAvailability method. func (client *Client) CheckNameAvailability(ctx context.Context, nameAvailabilityRequest CheckNameAvailabilityRequest, options *ClientCheckNameAvailabilityOptions) (ClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, nameAvailabilityRequest, options) if err != nil { return ClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCheckNameAvailabilityResponse{}, err } @@ -81,7 +72,7 @@ func (client *Client) checkNameAvailabilityCreateRequest(ctx context.Context, na return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_confidentialledger_client_test.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/client_example_test.go similarity index 52% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_confidentialledger_client_test.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/client_example_test.go index 3b943a1e237f..d99fa11ff060 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_confidentialledger_client_test.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/client_example_test.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger_test @@ -17,26 +18,28 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confidentialledger/armconfidentialledger" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/CheckNameAvailability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/CheckNameAvailability.json func ExampleClient_CheckNameAvailability() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconfidentialledger.NewClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, - armconfidentialledger.CheckNameAvailabilityRequest{ - Name: to.Ptr("sample-name"), - Type: to.Ptr("Microsoft.ConfidentialLedger/ledgers"), - }, - nil) + res, err := clientFactory.NewClient().CheckNameAvailability(ctx, armconfidentialledger.CheckNameAvailabilityRequest{ + Name: to.Ptr("sample-name"), + Type: to.Ptr("Microsoft.ConfidentialLedger/ledgers"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckNameAvailabilityResponse = armconfidentialledger.CheckNameAvailabilityResponse{ + // NameAvailable: to.Ptr(true), + // } } diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/client_factory.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/client_factory.go new file mode 100644 index 000000000000..948060097a8e --- /dev/null +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/client_factory.go @@ -0,0 +1,54 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfidentialledger + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLedgerClient() *LedgerClient { + subClient, _ := NewLedgerClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_constants.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/constants.go similarity index 98% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_constants.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/constants.go index 7ddb488fb6f0..d167c657911b 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_constants.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/constants.go @@ -5,12 +5,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger const ( moduleName = "armconfidentialledger" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CheckNameAvailabilityReason - The reason why the given name is not available. diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.mod b/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.mod index 4b5b4ae0e2c6..dca2d806870d 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.mod +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confidentialledger/ go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.sum b/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.sum +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_ledger_client.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/ledger_client.go similarity index 85% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_ledger_client.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/ledger_client.go index 4d5d842c018e..bfe672926fe3 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_ledger_client.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/ledger_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // LedgerClient contains the methods for the Ledger group. // Don't use this type directly, use NewLedgerClient() instead. type LedgerClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLedgerClient creates a new instance of LedgerClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLedgerClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LedgerClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LedgerClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LedgerClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates a Confidential Ledger with the specified ledger parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// resourceGroupName - The name of the resource group. -// ledgerName - Name of the Confidential Ledger -// confidentialLedger - Confidential Ledger Create Request Body -// options - LedgerClientBeginCreateOptions contains the optional parameters for the LedgerClient.BeginCreate method. +// - resourceGroupName - The name of the resource group. +// - ledgerName - Name of the Confidential Ledger +// - confidentialLedger - Confidential Ledger Create Request Body +// - options - LedgerClientBeginCreateOptions contains the optional parameters for the LedgerClient.BeginCreate method. func (client *LedgerClient) BeginCreate(ctx context.Context, resourceGroupName string, ledgerName string, confidentialLedger ConfidentialLedger, options *LedgerClientBeginCreateOptions) (*runtime.Poller[LedgerClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, ledgerName, confidentialLedger, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[LedgerClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LedgerClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[LedgerClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LedgerClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a Confidential Ledger with the specified ledger parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 func (client *LedgerClient) create(ctx context.Context, resourceGroupName string, ledgerName string, confidentialLedger ConfidentialLedger, options *LedgerClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, ledgerName, confidentialLedger, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -108,7 +100,7 @@ func (client *LedgerClient) createCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter ledgerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ledgerName}", url.PathEscape(ledgerName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,31 +113,33 @@ func (client *LedgerClient) createCreateRequest(ctx context.Context, resourceGro // BeginDelete - Deletes an existing Confidential Ledger. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// resourceGroupName - The name of the resource group. -// ledgerName - Name of the Confidential Ledger -// options - LedgerClientBeginDeleteOptions contains the optional parameters for the LedgerClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. +// - ledgerName - Name of the Confidential Ledger +// - options - LedgerClientBeginDeleteOptions contains the optional parameters for the LedgerClient.BeginDelete method. func (client *LedgerClient) BeginDelete(ctx context.Context, resourceGroupName string, ledgerName string, options *LedgerClientBeginDeleteOptions) (*runtime.Poller[LedgerClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, ledgerName, options) if err != nil { return nil, err } - return runtime.NewPoller[LedgerClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[LedgerClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LedgerClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LedgerClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an existing Confidential Ledger. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 func (client *LedgerClient) deleteOperation(ctx context.Context, resourceGroupName string, ledgerName string, options *LedgerClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, ledgerName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -170,7 +164,7 @@ func (client *LedgerClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter ledgerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ledgerName}", url.PathEscape(ledgerName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -183,16 +177,17 @@ func (client *LedgerClient) deleteCreateRequest(ctx context.Context, resourceGro // Get - Retrieves the properties of a Confidential Ledger. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// resourceGroupName - The name of the resource group. -// ledgerName - Name of the Confidential Ledger -// options - LedgerClientGetOptions contains the optional parameters for the LedgerClient.Get method. +// - resourceGroupName - The name of the resource group. +// - ledgerName - Name of the Confidential Ledger +// - options - LedgerClientGetOptions contains the optional parameters for the LedgerClient.Get method. func (client *LedgerClient) Get(ctx context.Context, resourceGroupName string, ledgerName string, options *LedgerClientGetOptions) (LedgerClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, ledgerName, options) if err != nil { return LedgerClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LedgerClientGetResponse{}, err } @@ -217,7 +212,7 @@ func (client *LedgerClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter ledgerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ledgerName}", url.PathEscape(ledgerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -238,11 +233,11 @@ func (client *LedgerClient) getHandleResponse(resp *http.Response) (LedgerClient } // NewListByResourceGroupPager - Retrieves the properties of all Confidential Ledgers. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// resourceGroupName - The name of the resource group. -// options - LedgerClientListByResourceGroupOptions contains the optional parameters for the LedgerClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. +// - options - LedgerClientListByResourceGroupOptions contains the optional parameters for the LedgerClient.NewListByResourceGroupPager +// method. func (client *LedgerClient) NewListByResourceGroupPager(resourceGroupName string, options *LedgerClientListByResourceGroupOptions) *runtime.Pager[LedgerClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[LedgerClientListByResourceGroupResponse]{ More: func(page LedgerClientListByResourceGroupResponse) bool { @@ -259,7 +254,7 @@ func (client *LedgerClient) NewListByResourceGroupPager(resourceGroupName string if err != nil { return LedgerClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LedgerClientListByResourceGroupResponse{}, err } @@ -282,7 +277,7 @@ func (client *LedgerClient) listByResourceGroupCreateRequest(ctx context.Context return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -306,10 +301,10 @@ func (client *LedgerClient) listByResourceGroupHandleResponse(resp *http.Respons } // NewListBySubscriptionPager - Retrieves the properties of all Confidential Ledgers. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// options - LedgerClientListBySubscriptionOptions contains the optional parameters for the LedgerClient.ListBySubscription -// method. +// - options - LedgerClientListBySubscriptionOptions contains the optional parameters for the LedgerClient.NewListBySubscriptionPager +// method. func (client *LedgerClient) NewListBySubscriptionPager(options *LedgerClientListBySubscriptionOptions) *runtime.Pager[LedgerClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[LedgerClientListBySubscriptionResponse]{ More: func(page LedgerClientListBySubscriptionResponse) bool { @@ -326,7 +321,7 @@ func (client *LedgerClient) NewListBySubscriptionPager(options *LedgerClientList if err != nil { return LedgerClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LedgerClientListBySubscriptionResponse{}, err } @@ -345,7 +340,7 @@ func (client *LedgerClient) listBySubscriptionCreateRequest(ctx context.Context, return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -370,32 +365,34 @@ func (client *LedgerClient) listBySubscriptionHandleResponse(resp *http.Response // BeginUpdate - Updates properties of Confidential Ledger // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// resourceGroupName - The name of the resource group. -// ledgerName - Name of the Confidential Ledger -// confidentialLedger - Confidential Ledger request body for Updating Ledger -// options - LedgerClientBeginUpdateOptions contains the optional parameters for the LedgerClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group. +// - ledgerName - Name of the Confidential Ledger +// - confidentialLedger - Confidential Ledger request body for Updating Ledger +// - options - LedgerClientBeginUpdateOptions contains the optional parameters for the LedgerClient.BeginUpdate method. func (client *LedgerClient) BeginUpdate(ctx context.Context, resourceGroupName string, ledgerName string, confidentialLedger ConfidentialLedger, options *LedgerClientBeginUpdateOptions) (*runtime.Poller[LedgerClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, ledgerName, confidentialLedger, options) if err != nil { return nil, err } - return runtime.NewPoller[LedgerClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[LedgerClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[LedgerClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[LedgerClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates properties of Confidential Ledger // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 func (client *LedgerClient) update(ctx context.Context, resourceGroupName string, ledgerName string, confidentialLedger ConfidentialLedger, options *LedgerClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, ledgerName, confidentialLedger, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -420,7 +417,7 @@ func (client *LedgerClient) updateCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter ledgerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ledgerName}", url.PathEscape(ledgerName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/ledger_client_example_test.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/ledger_client_example_test.go new file mode 100644 index 000000000000..da8337b93ed9 --- /dev/null +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/ledger_client_example_test.go @@ -0,0 +1,368 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfidentialledger_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confidentialledger/armconfidentialledger" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Get.json +func ExampleLedgerClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLedgerClient().Get(ctx, "DummyResourceGroupName", "DummyLedgerName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConfidentialLedger = armconfidentialledger.ConfidentialLedger{ + // Name: to.Ptr("DummyLedgerName"), + // Type: to.Ptr("Microsoft.ConfidentialLedger/ledgers"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.ConfidentialLedger/ledgers/DummyLedgerName"), + // SystemData: &armconfidentialledger.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00.1234567Z"); return t}()), + // CreatedBy: to.Ptr("ledgerAdmin@contoso.com"), + // CreatedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin1")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-02T00:00:00.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("ledgerAdmin2@outlook.com"), + // LastModifiedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin2")), + // }, + // Location: to.Ptr("EastUS"), + // Tags: map[string]*string{ + // "additionalProps1": to.Ptr("additional properties"), + // }, + // Properties: &armconfidentialledger.LedgerProperties{ + // AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ + // { + // LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), + // PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), + // TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), + // }}, + // IdentityServiceURI: to.Ptr("https://dummy.accledger.identity.com/DummyLedgerName"), + // LedgerInternalNamespace: to.Ptr("dummyNamespace"), + // LedgerName: to.Ptr("DummyLedgerName"), + // LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), + // LedgerURI: to.Ptr("https://dummy.accledger.domain.com/DummyLedgerName"), + // ProvisioningState: to.Ptr(armconfidentialledger.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Delete.json +func ExampleLedgerClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLedgerClient().BeginDelete(ctx, "DummyResourceGroupName", "DummyLedgerName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Create.json +func ExampleLedgerClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLedgerClient().BeginCreate(ctx, "DummyResourceGroupName", "DummyLedgerName", armconfidentialledger.ConfidentialLedger{ + Location: to.Ptr("EastUS"), + Tags: map[string]*string{ + "additionalProps1": to.Ptr("additional properties"), + }, + Properties: &armconfidentialledger.LedgerProperties{ + AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ + { + LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), + PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), + TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), + }}, + CertBasedSecurityPrincipals: []*armconfidentialledger.CertBasedSecurityPrincipal{ + { + Cert: to.Ptr("-----BEGIN CERTIFICATE-----MIIBsjCCATigAwIBAgIUZWIbyG79TniQLd2UxJuU74tqrKcwCgYIKoZIzj0EAwMwEDEOMAwGA1UEAwwFdXNlcjAwHhcNMjEwMzE2MTgwNjExWhcNMjIwMzE2MTgwNjExWjAQMQ4wDAYDVQQDDAV1c2VyMDB2MBAGByqGSM49AgEGBSuBBAAiA2IABBiWSo/j8EFit7aUMm5lF+lUmCu+IgfnpFD+7QMgLKtxRJ3aGSqgS/GpqcYVGddnODtSarNE/HyGKUFUolLPQ5ybHcouUk0kyfA7XMeSoUA4lBz63Wha8wmXo+NdBRo39qNTMFEwHQYDVR0OBBYEFPtuhrwgGjDFHeUUT4nGsXaZn69KMB8GA1UdIwQYMBaAFPtuhrwgGjDFHeUUT4nGsXaZn69KMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwMDaAAwZQIxAOnozm2CyqRwSSQLls5r+mUHRGRyXHXwYtM4Dcst/VEZdmS9fqvHRCHbjUlO/+HNfgIwMWZ4FmsjD3wnPxONOm9YdVn/PRD7SsPRPbOjwBiE4EBGaHDsLjYAGDSGi7NJnSkA-----END CERTIFICATE-----"), + LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameReader), + }}, + LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConfidentialLedger = armconfidentialledger.ConfidentialLedger{ + // Name: to.Ptr("DummyLedgerName"), + // Type: to.Ptr("Microsoft.ConfidentialLedger/ledgers"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.ConfidentialLedger/ledgers/DummyLedgerName"), + // SystemData: &armconfidentialledger.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00.1234567Z"); return t}()), + // CreatedBy: to.Ptr("ledgerAdmin@contoso.com"), + // CreatedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin1")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-02T00:00:00.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("ledgerAdmin2@outlook.com"), + // LastModifiedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin2")), + // }, + // Location: to.Ptr("EastUS"), + // Tags: map[string]*string{ + // "additionalProps1": to.Ptr("additional properties"), + // }, + // Properties: &armconfidentialledger.LedgerProperties{ + // AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ + // { + // LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), + // PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), + // TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), + // }}, + // CertBasedSecurityPrincipals: []*armconfidentialledger.CertBasedSecurityPrincipal{ + // { + // Cert: to.Ptr("-----BEGIN CERTIFICATE-----\nMIIDUjCCAjqgAwIBAgIQJ2IrDBawSkiAbkBYmiAopDANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwHhcNMjAwOTIzMjIxODQ2WhcNMjEwOTIzMjIyODQ2WjAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCX2s/Eu4q/eQ63N+Ugeg5oAciZua/YCJr41c/696szvSY7Zg1SNJlW88/nbz70+QpO55OmqlEE3QCU+T0Vl/h0Gf//n1PYcoBbTGUnYEmV+fTTHict6rFiEwrGJ62tvcpYgwapInSLyEeUzjki0zhOLJ1OfRnYd1eGnFVMpE5aVjiS8Q5dmTEUyd51EIprGE8RYAW9aeWSwTH7gjHUsRlJnHKcdhaK/v5QKJnNu5bzPFUcpC0ZBcizoMPAtroLAD4B68Jl0z3op18MgZe6lRrVoWuxfqnk5GojuB/Vu8ohAZKoFhQ6NB6r+LL2AUs+Zr7Bt26IkEdR178n9JMEA4gHAgMBAAGjfDB6MA4GA1UdDwEB/wQEAwIFoDAJBgNVHRMEAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBS/a7PU9iOfOKEyZCp11Oen5VSuuDAdBgNVHQ4EFgQUv2uz1PYjnzihMmQqddTnp+VUrrgwDQYJKoZIhvcNAQELBQADggEBAF5q2fDwnse8egXhfaJCqqM969E9gSacqFmASpoDJPRPEX7gqoO7v1ww7nqRtRDoRiBvo/yNk7jlSAkRN3nRRnZLZZ3MYQdmCr4FGyIqRg4Y94+nja+Du9pDD761rxRktMVPSOaAVM/E5DQvscDlPvlPYe9mkcrLCE4DXYpiMmLT8Tm55LJJq5m07dVDgzAIR1L/hmEcbK0pnLgzciMtMLxGO2udnyyW/UW9WxnjvrrD2JluTHH9mVbb+XQP1oFtlRBfH7aui1ZgWfKvxrdP4zdK9QoWSUvRux3TLsGmHRBjBMtqYDY3y5mB+aNjLelvWpeVb0m2aOSVXynrLwNCAVA=\n-----END CERTIFICATE-----"), + // LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameReader), + // }}, + // IdentityServiceURI: to.Ptr("https://dummy.accledger.identity.com/DummyLedgerName"), + // LedgerInternalNamespace: to.Ptr("dummyNamespace"), + // LedgerName: to.Ptr("DummyLedgerName"), + // LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), + // LedgerURI: to.Ptr("https://dummy.accledger.domain.com/DummyLedgerName"), + // ProvisioningState: to.Ptr(armconfidentialledger.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Update.json +func ExampleLedgerClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLedgerClient().BeginUpdate(ctx, "DummyResourceGroupName", "DummyLedgerName", armconfidentialledger.ConfidentialLedger{ + Location: to.Ptr("EastUS"), + Tags: map[string]*string{ + "additionProps2": to.Ptr("additional property value"), + "additionalProps1": to.Ptr("additional properties"), + }, + Properties: &armconfidentialledger.LedgerProperties{ + AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ + { + LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), + PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), + TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), + }}, + CertBasedSecurityPrincipals: []*armconfidentialledger.CertBasedSecurityPrincipal{ + { + Cert: to.Ptr("-----BEGIN CERTIFICATE-----\nMIIDUjCCAjqgAwIBAgIQJ2IrDBawSkiAbkBYmiAopDANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwHhcNMjAwOTIzMjIxODQ2WhcNMjEwOTIzMjIyODQ2WjAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCX2s/Eu4q/eQ63N+Ugeg5oAciZua/YCJr41c/696szvSY7Zg1SNJlW88/nbz70+QpO55OmqlEE3QCU+T0Vl/h0Gf//n1PYcoBbTGUnYEmV+fTTHict6rFiEwrGJ62tvcpYgwapInSLyEeUzjki0zhOLJ1OfRnYd1eGnFVMpE5aVjiS8Q5dmTEUyd51EIprGE8RYAW9aeWSwTH7gjHUsRlJnHKcdhaK/v5QKJnNu5bzPFUcpC0ZBcizoMPAtroLAD4B68Jl0z3op18MgZe6lRrVoWuxfqnk5GojuB/Vu8ohAZKoFhQ6NB6r+LL2AUs+Zr7Bt26IkEdR178n9JMEA4gHAgMBAAGjfDB6MA4GA1UdDwEB/wQEAwIFoDAJBgNVHRMEAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBS/a7PU9iOfOKEyZCp11Oen5VSuuDAdBgNVHQ4EFgQUv2uz1PYjnzihMmQqddTnp+VUrrgwDQYJKoZIhvcNAQELBQADggEBAF5q2fDwnse8egXhfaJCqqM969E9gSacqFmASpoDJPRPEX7gqoO7v1ww7nqRtRDoRiBvo/yNk7jlSAkRN3nRRnZLZZ3MYQdmCr4FGyIqRg4Y94+nja+Du9pDD761rxRktMVPSOaAVM/E5DQvscDlPvlPYe9mkcrLCE4DXYpiMmLT8Tm55LJJq5m07dVDgzAIR1L/hmEcbK0pnLgzciMtMLxGO2udnyyW/UW9WxnjvrrD2JluTHH9mVbb+XQP1oFtlRBfH7aui1ZgWfKvxrdP4zdK9QoWSUvRux3TLsGmHRBjBMtqYDY3y5mB+aNjLelvWpeVb0m2aOSVXynrLwNCAVA=\n-----END CERTIFICATE-----"), + LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameReader), + }}, + LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ConfidentialLedger = armconfidentialledger.ConfidentialLedger{ + // Name: to.Ptr("DummyLedgerName"), + // Type: to.Ptr("Microsoft.ConfidentialLedger/ledgers"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.ConfidentialLedger/ledgers/DummyLedgerName"), + // SystemData: &armconfidentialledger.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00.1234567Z"); return t}()), + // CreatedBy: to.Ptr("ledgerAdmin@contoso.com"), + // CreatedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin1")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-02T00:00:00.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("ledgerAdmin2@outlook.com"), + // LastModifiedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin2")), + // }, + // Location: to.Ptr("EastUS"), + // Tags: map[string]*string{ + // "additionProps2": to.Ptr("additional property value"), + // "additionalProps1": to.Ptr("additional properties"), + // }, + // Properties: &armconfidentialledger.LedgerProperties{ + // AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ + // { + // LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), + // PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), + // TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), + // }}, + // CertBasedSecurityPrincipals: []*armconfidentialledger.CertBasedSecurityPrincipal{ + // { + // Cert: to.Ptr("-----BEGIN CERTIFICATE-----\nMIIDUjCCAjqgAwIBAgIQJ2IrDBawSkiAbkBYmiAopDANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwHhcNMjAwOTIzMjIxODQ2WhcNMjEwOTIzMjIyODQ2WjAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCX2s/Eu4q/eQ63N+Ugeg5oAciZua/YCJr41c/696szvSY7Zg1SNJlW88/nbz70+QpO55OmqlEE3QCU+T0Vl/h0Gf//n1PYcoBbTGUnYEmV+fTTHict6rFiEwrGJ62tvcpYgwapInSLyEeUzjki0zhOLJ1OfRnYd1eGnFVMpE5aVjiS8Q5dmTEUyd51EIprGE8RYAW9aeWSwTH7gjHUsRlJnHKcdhaK/v5QKJnNu5bzPFUcpC0ZBcizoMPAtroLAD4B68Jl0z3op18MgZe6lRrVoWuxfqnk5GojuB/Vu8ohAZKoFhQ6NB6r+LL2AUs+Zr7Bt26IkEdR178n9JMEA4gHAgMBAAGjfDB6MA4GA1UdDwEB/wQEAwIFoDAJBgNVHRMEAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBS/a7PU9iOfOKEyZCp11Oen5VSuuDAdBgNVHQ4EFgQUv2uz1PYjnzihMmQqddTnp+VUrrgwDQYJKoZIhvcNAQELBQADggEBAF5q2fDwnse8egXhfaJCqqM969E9gSacqFmASpoDJPRPEX7gqoO7v1ww7nqRtRDoRiBvo/yNk7jlSAkRN3nRRnZLZZ3MYQdmCr4FGyIqRg4Y94+nja+Du9pDD761rxRktMVPSOaAVM/E5DQvscDlPvlPYe9mkcrLCE4DXYpiMmLT8Tm55LJJq5m07dVDgzAIR1L/hmEcbK0pnLgzciMtMLxGO2udnyyW/UW9WxnjvrrD2JluTHH9mVbb+XQP1oFtlRBfH7aui1ZgWfKvxrdP4zdK9QoWSUvRux3TLsGmHRBjBMtqYDY3y5mB+aNjLelvWpeVb0m2aOSVXynrLwNCAVA=\n-----END CERTIFICATE-----"), + // LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameReader), + // }}, + // IdentityServiceURI: to.Ptr("https://identity.confidential-ledger.core.azure.com/ledgerIdentity/dummyledgername"), + // LedgerInternalNamespace: to.Ptr("dummyNamespace"), + // LedgerName: to.Ptr("DummyLedgerName"), + // LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), + // LedgerURI: to.Ptr("https://dummyledgername.confidential-ledger.azure.com"), + // ProvisioningState: to.Ptr(armconfidentialledger.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_List.json +func ExampleLedgerClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLedgerClient().NewListByResourceGroupPager("DummyResourceGroupName", &armconfidentialledger.LedgerClientListByResourceGroupOptions{Filter: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.List = armconfidentialledger.List{ + // Value: []*armconfidentialledger.ConfidentialLedger{ + // { + // Name: to.Ptr("DummyLedgerName"), + // Type: to.Ptr("Microsoft.ConfidentialLedger/ledgers"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.ConfidentialLedger/ledgers/DummyLedgerName"), + // SystemData: &armconfidentialledger.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00.1234567Z"); return t}()), + // CreatedBy: to.Ptr("ledgerAdmin@contoso.com"), + // CreatedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin1")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-02T00:00:00.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("ledgerAdmin2@outlook.com"), + // LastModifiedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin2")), + // }, + // Location: to.Ptr("EastUS"), + // Tags: map[string]*string{ + // "additionalProps1": to.Ptr("additional properties"), + // }, + // Properties: &armconfidentialledger.LedgerProperties{ + // AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ + // { + // LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), + // PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), + // TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), + // }}, + // IdentityServiceURI: to.Ptr("https://dummy.accledger.identity.com/DummyLedgerName"), + // LedgerInternalNamespace: to.Ptr("dummyNamespace"), + // LedgerName: to.Ptr("DummyLedgerName"), + // LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), + // LedgerURI: to.Ptr("https://dummy.accledger.domain.com/DummyLedgerName"), + // ProvisioningState: to.Ptr(armconfidentialledger.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_ListBySub.json +func ExampleLedgerClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLedgerClient().NewListBySubscriptionPager(&armconfidentialledger.LedgerClientListBySubscriptionOptions{Filter: nil}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.List = armconfidentialledger.List{ + // Value: []*armconfidentialledger.ConfidentialLedger{ + // { + // Name: to.Ptr("DummyLedgerName"), + // Type: to.Ptr("Microsoft.ConfidentialLedger/ledgers"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.ConfidentialLedger/ledgers/DummyLedgerName"), + // SystemData: &armconfidentialledger.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T00:00:00.1234567Z"); return t}()), + // CreatedBy: to.Ptr("ledgerAdmin@contoso.com"), + // CreatedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin1")), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-02T00:00:00.1234567Z"); return t}()), + // LastModifiedBy: to.Ptr("ledgerAdmin2@outlook.com"), + // LastModifiedByType: to.Ptr(armconfidentialledger.CreatedByType("Admin2")), + // }, + // Location: to.Ptr("EastUS"), + // Tags: map[string]*string{ + // "additionalProps1": to.Ptr("additional properties"), + // }, + // Properties: &armconfidentialledger.LedgerProperties{ + // CertBasedSecurityPrincipals: []*armconfidentialledger.CertBasedSecurityPrincipal{ + // { + // Cert: to.Ptr("-----BEGIN CERTIFICATE-----\nMIIDUjCCAjqgAwIBAgIQJ2IrDBawSkiAbkBYmiAopDANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwHhcNMjAwOTIzMjIxODQ2WhcNMjEwOTIzMjIyODQ2WjAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCX2s/Eu4q/eQ63N+Ugeg5oAciZua/YCJr41c/696szvSY7Zg1SNJlW88/nbz70+QpO55OmqlEE3QCU+T0Vl/h0Gf//n1PYcoBbTGUnYEmV+fTTHict6rFiEwrGJ62tvcpYgwapInSLyEeUzjki0zhOLJ1OfRnYd1eGnFVMpE5aVjiS8Q5dmTEUyd51EIprGE8RYAW9aeWSwTH7gjHUsRlJnHKcdhaK/v5QKJnNu5bzPFUcpC0ZBcizoMPAtroLAD4B68Jl0z3op18MgZe6lRrVoWuxfqnk5GojuB/Vu8ohAZKoFhQ6NB6r+LL2AUs+Zr7Bt26IkEdR178n9JMEA4gHAgMBAAGjfDB6MA4GA1UdDwEB/wQEAwIFoDAJBgNVHRMEAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBS/a7PU9iOfOKEyZCp11Oen5VSuuDAdBgNVHQ4EFgQUv2uz1PYjnzihMmQqddTnp+VUrrgwDQYJKoZIhvcNAQELBQADggEBAF5q2fDwnse8egXhfaJCqqM969E9gSacqFmASpoDJPRPEX7gqoO7v1ww7nqRtRDoRiBvo/yNk7jlSAkRN3nRRnZLZZ3MYQdmCr4FGyIqRg4Y94+nja+Du9pDD761rxRktMVPSOaAVM/E5DQvscDlPvlPYe9mkcrLCE4DXYpiMmLT8Tm55LJJq5m07dVDgzAIR1L/hmEcbK0pnLgzciMtMLxGO2udnyyW/UW9WxnjvrrD2JluTHH9mVbb+XQP1oFtlRBfH7aui1ZgWfKvxrdP4zdK9QoWSUvRux3TLsGmHRBjBMtqYDY3y5mB+aNjLelvWpeVb0m2aOSVXynrLwNCAVA=\n-----END CERTIFICATE-----"), + // LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameReader), + // }}, + // IdentityServiceURI: to.Ptr("https://dummy.accledger.identity.com/DummyLedgerName"), + // LedgerInternalNamespace: to.Ptr("dummyNamespace"), + // LedgerName: to.Ptr("DummyLedgerName"), + // LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), + // LedgerURI: to.Ptr("https://dummy.accledger.domain.com/DummyLedgerName"), + // ProvisioningState: to.Ptr(armconfidentialledger.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_models.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/models.go similarity index 97% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_models.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/models.go index 900f645cd60d..31e4b74c641d 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_models.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger @@ -84,7 +85,7 @@ type ConfidentialLedger struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -138,13 +139,15 @@ type LedgerClientGetOptions struct { // placeholder for future optional parameters } -// LedgerClientListByResourceGroupOptions contains the optional parameters for the LedgerClient.ListByResourceGroup method. +// LedgerClientListByResourceGroupOptions contains the optional parameters for the LedgerClient.NewListByResourceGroupPager +// method. type LedgerClientListByResourceGroupOptions struct { // The filter to apply on the list operation. eg. $filter=ledgerType eq 'Public' Filter *string } -// LedgerClientListBySubscriptionOptions contains the optional parameters for the LedgerClient.ListBySubscription method. +// LedgerClientListBySubscriptionOptions contains the optional parameters for the LedgerClient.NewListBySubscriptionPager +// method. type LedgerClientListBySubscriptionOptions struct { // The filter to apply on the list operation. eg. $filter=ledgerType eq 'Public' Filter *string @@ -186,7 +189,7 @@ type List struct { Value []*ConfidentialLedger `json:"value,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/models_serde.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/models_serde.go new file mode 100644 index 000000000000..13abce06e465 --- /dev/null +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/models_serde.go @@ -0,0 +1,652 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfidentialledger + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AADBasedSecurityPrincipal. +func (a AADBasedSecurityPrincipal) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ledgerRoleName", a.LedgerRoleName) + populate(objectMap, "principalId", a.PrincipalID) + populate(objectMap, "tenantId", a.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AADBasedSecurityPrincipal. +func (a *AADBasedSecurityPrincipal) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ledgerRoleName": + err = unpopulate(val, "LedgerRoleName", &a.LedgerRoleName) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &a.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &a.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CertBasedSecurityPrincipal. +func (c CertBasedSecurityPrincipal) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cert", c.Cert) + populate(objectMap, "ledgerRoleName", c.LedgerRoleName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertBasedSecurityPrincipal. +func (c *CertBasedSecurityPrincipal) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cert": + err = unpopulate(val, "Cert", &c.Cert) + delete(rawMsg, key) + case "ledgerRoleName": + err = unpopulate(val, "LedgerRoleName", &c.LedgerRoleName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. +func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. +func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponse. +func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. +func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfidentialLedger. +func (c ConfidentialLedger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfidentialLedger. +func (c *ConfidentialLedger) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LedgerProperties. +func (l LedgerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aadBasedSecurityPrincipals", l.AADBasedSecurityPrincipals) + populate(objectMap, "certBasedSecurityPrincipals", l.CertBasedSecurityPrincipals) + populate(objectMap, "identityServiceUri", l.IdentityServiceURI) + populate(objectMap, "ledgerInternalNamespace", l.LedgerInternalNamespace) + populate(objectMap, "ledgerName", l.LedgerName) + populate(objectMap, "ledgerType", l.LedgerType) + populate(objectMap, "ledgerUri", l.LedgerURI) + populate(objectMap, "provisioningState", l.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LedgerProperties. +func (l *LedgerProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aadBasedSecurityPrincipals": + err = unpopulate(val, "AADBasedSecurityPrincipals", &l.AADBasedSecurityPrincipals) + delete(rawMsg, key) + case "certBasedSecurityPrincipals": + err = unpopulate(val, "CertBasedSecurityPrincipals", &l.CertBasedSecurityPrincipals) + delete(rawMsg, key) + case "identityServiceUri": + err = unpopulate(val, "IdentityServiceURI", &l.IdentityServiceURI) + delete(rawMsg, key) + case "ledgerInternalNamespace": + err = unpopulate(val, "LedgerInternalNamespace", &l.LedgerInternalNamespace) + delete(rawMsg, key) + case "ledgerName": + err = unpopulate(val, "LedgerName", &l.LedgerName) + delete(rawMsg, key) + case "ledgerType": + err = unpopulate(val, "LedgerType", &l.LedgerType) + delete(rawMsg, key) + case "ledgerUri": + err = unpopulate(val, "LedgerURI", &l.LedgerURI) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type List. +func (l List) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type List. +func (l *List) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceLocation. +func (r ResourceLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", r.Location) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLocation. +func (r *ResourceLocation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationDefinition. +func (r ResourceProviderOperationDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", r.Display) + populate(objectMap, "isDataAction", r.IsDataAction) + populate(objectMap, "name", r.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDefinition. +func (r *ResourceProviderOperationDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &r.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &r.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationDisplay. +func (r ResourceProviderOperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", r.Description) + populate(objectMap, "operation", r.Operation) + populate(objectMap, "provider", r.Provider) + populate(objectMap, "resource", r.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDisplay. +func (r *ResourceProviderOperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &r.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &r.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &r.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationList. +func (r ResourceProviderOperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationList. +func (r *ResourceProviderOperationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Tags. +func (t Tags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Tags. +func (t *Tags) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_operations_client.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/operations_client.go similarity index 77% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_operations_client.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/operations_client.go index 3d4b8f286d76..e8db5ed89add 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_operations_client.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/operations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Retrieves a list of available API operations -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-05-13 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.ConfidentialLedger/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/operations_client_example_test.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/operations_client_example_test.go new file mode 100644 index 000000000000..eff4cf328c5e --- /dev/null +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/operations_client_example_test.go @@ -0,0 +1,55 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfidentialledger_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confidentialledger/armconfidentialledger" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/792db17291c758b2bfdbbc0d35d0e2f5b5a1bd05/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/Operations_Get.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfidentialledger.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ResourceProviderOperationList = armconfidentialledger.ResourceProviderOperationList{ + // Value: []*armconfidentialledger.ResourceProviderOperationDefinition{ + // { + // Name: to.Ptr("Microsoft.ConfidentialLedger/ledgers/read"), + // Display: &armconfidentialledger.ResourceProviderOperationDisplay{ + // Description: to.Ptr("View the properties of a Confidential Ledger"), + // Operation: to.Ptr("Get Confidential Ledger properties"), + // Resource: to.Ptr("ledger"), + // }, + // IsDataAction: to.Ptr(false), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_response_types.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/response_types.go similarity index 86% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_response_types.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/response_types.go index ef876d395f5d..850ad5b9b622 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_response_types.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger @@ -13,12 +14,12 @@ type ClientCheckNameAvailabilityResponse struct { CheckNameAvailabilityResponse } -// LedgerClientCreateResponse contains the response from method LedgerClient.Create. +// LedgerClientCreateResponse contains the response from method LedgerClient.BeginCreate. type LedgerClientCreateResponse struct { ConfidentialLedger } -// LedgerClientDeleteResponse contains the response from method LedgerClient.Delete. +// LedgerClientDeleteResponse contains the response from method LedgerClient.BeginDelete. type LedgerClientDeleteResponse struct { // placeholder for future response values } @@ -28,22 +29,22 @@ type LedgerClientGetResponse struct { ConfidentialLedger } -// LedgerClientListByResourceGroupResponse contains the response from method LedgerClient.ListByResourceGroup. +// LedgerClientListByResourceGroupResponse contains the response from method LedgerClient.NewListByResourceGroupPager. type LedgerClientListByResourceGroupResponse struct { List } -// LedgerClientListBySubscriptionResponse contains the response from method LedgerClient.ListBySubscription. +// LedgerClientListBySubscriptionResponse contains the response from method LedgerClient.NewListBySubscriptionPager. type LedgerClientListBySubscriptionResponse struct { List } -// LedgerClientUpdateResponse contains the response from method LedgerClient.Update. +// LedgerClientUpdateResponse contains the response from method LedgerClient.BeginUpdate. type LedgerClientUpdateResponse struct { ConfidentialLedger } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { ResourceProviderOperationList } diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_time_rfc3339.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/confidentialledger/armconfidentialledger/time_rfc3339.go index 75bc94798e7c..e81d39909c33 100644 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/confidentialledger/armconfidentialledger/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfidentialledger @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_ledger_client_test.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_ledger_client_test.go deleted file mode 100644 index 6be3127bc463..000000000000 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_ledger_client_test.go +++ /dev/null @@ -1,206 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfidentialledger_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confidentialledger/armconfidentialledger" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Get.json -func ExampleLedgerClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfidentialledger.NewLedgerClient("0000000-0000-0000-0000-000000000001", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "DummyResourceGroupName", - "DummyLedgerName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Delete.json -func ExampleLedgerClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfidentialledger.NewLedgerClient("0000000-0000-0000-0000-000000000001", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "DummyResourceGroupName", - "DummyLedgerName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Create.json -func ExampleLedgerClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfidentialledger.NewLedgerClient("0000000-0000-0000-0000-000000000001", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "DummyResourceGroupName", - "DummyLedgerName", - armconfidentialledger.ConfidentialLedger{ - Location: to.Ptr("EastUS"), - Tags: map[string]*string{ - "additionalProps1": to.Ptr("additional properties"), - }, - Properties: &armconfidentialledger.LedgerProperties{ - AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ - { - LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), - PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), - TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), - }}, - CertBasedSecurityPrincipals: []*armconfidentialledger.CertBasedSecurityPrincipal{ - { - Cert: to.Ptr("-----BEGIN CERTIFICATE-----MIIBsjCCATigAwIBAgIUZWIbyG79TniQLd2UxJuU74tqrKcwCgYIKoZIzj0EAwMwEDEOMAwGA1UEAwwFdXNlcjAwHhcNMjEwMzE2MTgwNjExWhcNMjIwMzE2MTgwNjExWjAQMQ4wDAYDVQQDDAV1c2VyMDB2MBAGByqGSM49AgEGBSuBBAAiA2IABBiWSo/j8EFit7aUMm5lF+lUmCu+IgfnpFD+7QMgLKtxRJ3aGSqgS/GpqcYVGddnODtSarNE/HyGKUFUolLPQ5ybHcouUk0kyfA7XMeSoUA4lBz63Wha8wmXo+NdBRo39qNTMFEwHQYDVR0OBBYEFPtuhrwgGjDFHeUUT4nGsXaZn69KMB8GA1UdIwQYMBaAFPtuhrwgGjDFHeUUT4nGsXaZn69KMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwMDaAAwZQIxAOnozm2CyqRwSSQLls5r+mUHRGRyXHXwYtM4Dcst/VEZdmS9fqvHRCHbjUlO/+HNfgIwMWZ4FmsjD3wnPxONOm9YdVn/PRD7SsPRPbOjwBiE4EBGaHDsLjYAGDSGi7NJnSkA-----END CERTIFICATE-----"), - LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameReader), - }}, - LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_Update.json -func ExampleLedgerClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfidentialledger.NewLedgerClient("0000000-0000-0000-0000-000000000001", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "DummyResourceGroupName", - "DummyLedgerName", - armconfidentialledger.ConfidentialLedger{ - Location: to.Ptr("EastUS"), - Tags: map[string]*string{ - "additionProps2": to.Ptr("additional property value"), - "additionalProps1": to.Ptr("additional properties"), - }, - Properties: &armconfidentialledger.LedgerProperties{ - AADBasedSecurityPrincipals: []*armconfidentialledger.AADBasedSecurityPrincipal{ - { - LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameAdministrator), - PrincipalID: to.Ptr("34621747-6fc8-4771-a2eb-72f31c461f2e"), - TenantID: to.Ptr("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), - }}, - CertBasedSecurityPrincipals: []*armconfidentialledger.CertBasedSecurityPrincipal{ - { - Cert: to.Ptr("-----BEGIN CERTIFICATE-----\nMIIDUjCCAjqgAwIBAgIQJ2IrDBawSkiAbkBYmiAopDANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwHhcNMjAwOTIzMjIxODQ2WhcNMjEwOTIzMjIyODQ2WjAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCX2s/Eu4q/eQ63N+Ugeg5oAciZua/YCJr41c/696szvSY7Zg1SNJlW88/nbz70+QpO55OmqlEE3QCU+T0Vl/h0Gf//n1PYcoBbTGUnYEmV+fTTHict6rFiEwrGJ62tvcpYgwapInSLyEeUzjki0zhOLJ1OfRnYd1eGnFVMpE5aVjiS8Q5dmTEUyd51EIprGE8RYAW9aeWSwTH7gjHUsRlJnHKcdhaK/v5QKJnNu5bzPFUcpC0ZBcizoMPAtroLAD4B68Jl0z3op18MgZe6lRrVoWuxfqnk5GojuB/Vu8ohAZKoFhQ6NB6r+LL2AUs+Zr7Bt26IkEdR178n9JMEA4gHAgMBAAGjfDB6MA4GA1UdDwEB/wQEAwIFoDAJBgNVHRMEAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBS/a7PU9iOfOKEyZCp11Oen5VSuuDAdBgNVHQ4EFgQUv2uz1PYjnzihMmQqddTnp+VUrrgwDQYJKoZIhvcNAQELBQADggEBAF5q2fDwnse8egXhfaJCqqM969E9gSacqFmASpoDJPRPEX7gqoO7v1ww7nqRtRDoRiBvo/yNk7jlSAkRN3nRRnZLZZ3MYQdmCr4FGyIqRg4Y94+nja+Du9pDD761rxRktMVPSOaAVM/E5DQvscDlPvlPYe9mkcrLCE4DXYpiMmLT8Tm55LJJq5m07dVDgzAIR1L/hmEcbK0pnLgzciMtMLxGO2udnyyW/UW9WxnjvrrD2JluTHH9mVbb+XQP1oFtlRBfH7aui1ZgWfKvxrdP4zdK9QoWSUvRux3TLsGmHRBjBMtqYDY3y5mB+aNjLelvWpeVb0m2aOSVXynrLwNCAVA=\n-----END CERTIFICATE-----"), - LedgerRoleName: to.Ptr(armconfidentialledger.LedgerRoleNameReader), - }}, - LedgerType: to.Ptr(armconfidentialledger.LedgerTypePublic), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_List.json -func ExampleLedgerClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfidentialledger.NewLedgerClient("0000000-0000-0000-0000-000000000001", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("DummyResourceGroupName", - &armconfidentialledger.LedgerClientListByResourceGroupOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/ConfidentialLedger_ListBySub.json -func ExampleLedgerClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfidentialledger.NewLedgerClient("0000000-0000-0000-0000-000000000001", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armconfidentialledger.LedgerClientListBySubscriptionOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_operations_client_test.go deleted file mode 100644 index ef09ca2dc3e6..000000000000 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfidentialledger_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confidentialledger/armconfidentialledger" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/stable/2022-05-13/examples/Operations_Get.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfidentialledger.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_models_serde.go b/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_models_serde.go deleted file mode 100644 index 5a93de84b70f..000000000000 --- a/sdk/resourcemanager/confidentialledger/armconfidentialledger/zz_generated_models_serde.go +++ /dev/null @@ -1,117 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfidentialledger - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type ConfidentialLedger. -func (c ConfidentialLedger) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", c.ID) - populate(objectMap, "location", c.Location) - populate(objectMap, "name", c.Name) - populate(objectMap, "properties", c.Properties) - populate(objectMap, "systemData", c.SystemData) - populate(objectMap, "tags", c.Tags) - populate(objectMap, "type", c.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LedgerProperties. -func (l LedgerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aadBasedSecurityPrincipals", l.AADBasedSecurityPrincipals) - populate(objectMap, "certBasedSecurityPrincipals", l.CertBasedSecurityPrincipals) - populate(objectMap, "identityServiceUri", l.IdentityServiceURI) - populate(objectMap, "ledgerInternalNamespace", l.LedgerInternalNamespace) - populate(objectMap, "ledgerName", l.LedgerName) - populate(objectMap, "ledgerType", l.LedgerType) - populate(objectMap, "ledgerUri", l.LedgerURI) - populate(objectMap, "provisioningState", l.ProvisioningState) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Tags. -func (t Tags) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", t.Tags) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md index 76eccde41e6e..ad37ecec75d7 100644 --- a/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md +++ b/sdk/resourcemanager/confluent/armconfluent/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/confluent/armconfluent/README.md b/sdk/resourcemanager/confluent/armconfluent/README.md index da95100fa64c..9477dd05cb68 100644 --- a/sdk/resourcemanager/confluent/armconfluent/README.md +++ b/sdk/resourcemanager/confluent/armconfluent/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Confluent modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Confluent module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armconfluent.NewMarketplaceAgreementsClient(, cred, nil) +clientFactory, err := armconfluent.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armconfluent.NewMarketplaceAgreementsClient(, cred, &options) +clientFactory, err := armconfluent.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewOrganizationClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/confluent/armconfluent/autorest.md b/sdk/resourcemanager/confluent/armconfluent/autorest.md index 0ddc97b0061a..d9a2d1f6e554 100644 --- a/sdk/resourcemanager/confluent/armconfluent/autorest.md +++ b/sdk/resourcemanager/confluent/armconfluent/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/confluent/armconfluent/client_factory.go b/sdk/resourcemanager/confluent/armconfluent/client_factory.go new file mode 100644 index 000000000000..46213fb3ce38 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/client_factory.go @@ -0,0 +1,59 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfluent + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Microsoft Azure subscription id +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewMarketplaceAgreementsClient() *MarketplaceAgreementsClient { + subClient, _ := NewMarketplaceAgreementsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOrganizationOperationsClient() *OrganizationOperationsClient { + subClient, _ := NewOrganizationOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOrganizationClient() *OrganizationClient { + subClient, _ := NewOrganizationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewValidationsClient() *ValidationsClient { + subClient, _ := NewValidationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_constants.go b/sdk/resourcemanager/confluent/armconfluent/constants.go similarity index 98% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_constants.go rename to sdk/resourcemanager/confluent/armconfluent/constants.go index 864f54306d0a..7eafaba100a8 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_constants.go +++ b/sdk/resourcemanager/confluent/armconfluent/constants.go @@ -5,12 +5,13 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent const ( moduleName = "armconfluent" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/confluent/armconfluent/go.mod b/sdk/resourcemanager/confluent/armconfluent/go.mod index 788fe38c194c..bed0f8d841ed 100644 --- a/sdk/resourcemanager/confluent/armconfluent/go.mod +++ b/sdk/resourcemanager/confluent/armconfluent/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconflu go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/confluent/armconfluent/go.sum b/sdk/resourcemanager/confluent/armconfluent/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/confluent/armconfluent/go.sum +++ b/sdk/resourcemanager/confluent/armconfluent/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_marketplaceagreements_client.go b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client.go similarity index 82% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_marketplaceagreements_client.go rename to sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client.go index 83325ec14b30..aef906962960 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_marketplaceagreements_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,46 +24,38 @@ import ( // MarketplaceAgreementsClient contains the methods for the MarketplaceAgreements group. // Don't use this type directly, use NewMarketplaceAgreementsClient() instead. type MarketplaceAgreementsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMarketplaceAgreementsClient creates a new instance of MarketplaceAgreementsClient with the specified values. -// subscriptionID - Microsoft Azure subscription id -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Microsoft Azure subscription id +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMarketplaceAgreementsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MarketplaceAgreementsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MarketplaceAgreementsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MarketplaceAgreementsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create Confluent Marketplace agreement in the subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - MarketplaceAgreementsClientCreateOptions contains the optional parameters for the MarketplaceAgreementsClient.Create -// method. +// - options - MarketplaceAgreementsClientCreateOptions contains the optional parameters for the MarketplaceAgreementsClient.Create +// method. func (client *MarketplaceAgreementsClient) Create(ctx context.Context, options *MarketplaceAgreementsClientCreateOptions) (MarketplaceAgreementsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, options) if err != nil { return MarketplaceAgreementsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientCreateResponse{}, err } @@ -81,7 +72,7 @@ func (client *MarketplaceAgreementsClient) createCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -105,10 +96,10 @@ func (client *MarketplaceAgreementsClient) createHandleResponse(resp *http.Respo } // NewListPager - List Confluent marketplace agreements in the subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.List -// method. +// - options - MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.NewListPager +// method. func (client *MarketplaceAgreementsClient) NewListPager(options *MarketplaceAgreementsClientListOptions) *runtime.Pager[MarketplaceAgreementsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MarketplaceAgreementsClientListResponse]{ More: func(page MarketplaceAgreementsClientListResponse) bool { @@ -125,7 +116,7 @@ func (client *MarketplaceAgreementsClient) NewListPager(options *MarketplaceAgre if err != nil { return MarketplaceAgreementsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MarketplaceAgreementsClientListResponse{}, err } @@ -144,7 +135,7 @@ func (client *MarketplaceAgreementsClient) listCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go new file mode 100644 index 000000000000..849f897ccbf7 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/marketplaceagreements_client_example_test.go @@ -0,0 +1,119 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfluent_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/MarketplaceAgreements_List.json +func ExampleMarketplaceAgreementsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMarketplaceAgreementsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AgreementResourceListResponse = armconfluent.AgreementResourceListResponse{ + // Value: []*armconfluent.AgreementResource{ + // { + // Name: to.Ptr("planid1"), + // Type: to.Ptr("Microsoft.Confluent/agreements"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Confluent/agreements/default"), + // Properties: &armconfluent.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLink1"), + // Plan: to.Ptr("planid1"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink1"), + // Product: to.Ptr("offid1"), + // Publisher: to.Ptr("pubid1"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // }, + // { + // Name: to.Ptr("planid2"), + // Type: to.Ptr("Microsoft.MarketplaceOrdering/offertypes"), + // ID: to.Ptr("id2"), + // Properties: &armconfluent.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLin2k"), + // Plan: to.Ptr("planid2"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink2"), + // Product: to.Ptr("offid2"), + // Publisher: to.Ptr("pubid2"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-14T11:33:07.12132Z"); return t}()), + // Signature: to.Ptr("ASDFSDAFWEFASDGWERLWER"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/MarketplaceAgreements_Create.json +func ExampleMarketplaceAgreementsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMarketplaceAgreementsClient().Create(ctx, &armconfluent.MarketplaceAgreementsClientCreateOptions{Body: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AgreementResource = armconfluent.AgreementResource{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Confluent/agreements"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Confluent/agreements/default"), + // Properties: &armconfluent.AgreementProperties{ + // Accepted: to.Ptr(true), + // LicenseTextLink: to.Ptr("test.licenseLink1"), + // Plan: to.Ptr("planid1"), + // PrivacyPolicyLink: to.Ptr("test.privacyPolicyLink1"), + // Product: to.Ptr("offid1"), + // Publisher: to.Ptr("pubid1"), + // RetrieveDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-05T17:33:07.12132Z"); return t}()), + // Signature: to.Ptr("YKWOQOKH2BCKZ46O7SCKHANWEENRFRU5WB4LXDFUYWCBWTS4AG4SGQXCOZYIR5ZJCZTXRMZKYZMO2BJSL5YKPLAR4LBFRUNS6CRYE7A"), + // }, + // SystemData: &armconfluent.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // }, + // } +} diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_models.go b/sdk/resourcemanager/confluent/armconfluent/models.go similarity index 97% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_models.go rename to sdk/resourcemanager/confluent/armconfluent/models.go index 8f6f8170622c..5b114c0d907e 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_models.go +++ b/sdk/resourcemanager/confluent/armconfluent/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent @@ -85,7 +86,8 @@ type MarketplaceAgreementsClientCreateOptions struct { Body *AgreementResource } -// MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.List method. +// MarketplaceAgreementsClientListOptions contains the optional parameters for the MarketplaceAgreementsClient.NewListPager +// method. type MarketplaceAgreementsClientListOptions struct { // placeholder for future optional parameters } @@ -166,13 +168,13 @@ type OrganizationClientGetOptions struct { // placeholder for future optional parameters } -// OrganizationClientListByResourceGroupOptions contains the optional parameters for the OrganizationClient.ListByResourceGroup +// OrganizationClientListByResourceGroupOptions contains the optional parameters for the OrganizationClient.NewListByResourceGroupPager // method. type OrganizationClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// OrganizationClientListBySubscriptionOptions contains the optional parameters for the OrganizationClient.ListBySubscription +// OrganizationClientListBySubscriptionOptions contains the optional parameters for the OrganizationClient.NewListBySubscriptionPager // method. type OrganizationClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -184,7 +186,8 @@ type OrganizationClientUpdateOptions struct { Body *OrganizationResourceUpdate } -// OrganizationOperationsClientListOptions contains the optional parameters for the OrganizationOperationsClient.List method. +// OrganizationOperationsClientListOptions contains the optional parameters for the OrganizationOperationsClient.NewListPager +// method. type OrganizationOperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/confluent/armconfluent/models_serde.go b/sdk/resourcemanager/confluent/armconfluent/models_serde.go new file mode 100644 index 000000000000..029e5478ea2b --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/models_serde.go @@ -0,0 +1,622 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfluent + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AgreementProperties. +func (a AgreementProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accepted", a.Accepted) + populate(objectMap, "licenseTextLink", a.LicenseTextLink) + populate(objectMap, "plan", a.Plan) + populate(objectMap, "privacyPolicyLink", a.PrivacyPolicyLink) + populate(objectMap, "product", a.Product) + populate(objectMap, "publisher", a.Publisher) + populateTimeRFC3339(objectMap, "retrieveDatetime", a.RetrieveDatetime) + populate(objectMap, "signature", a.Signature) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementProperties. +func (a *AgreementProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accepted": + err = unpopulate(val, "Accepted", &a.Accepted) + delete(rawMsg, key) + case "licenseTextLink": + err = unpopulate(val, "LicenseTextLink", &a.LicenseTextLink) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &a.Plan) + delete(rawMsg, key) + case "privacyPolicyLink": + err = unpopulate(val, "PrivacyPolicyLink", &a.PrivacyPolicyLink) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &a.Product) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &a.Publisher) + delete(rawMsg, key) + case "retrieveDatetime": + err = unpopulateTimeRFC3339(val, "RetrieveDatetime", &a.RetrieveDatetime) + delete(rawMsg, key) + case "signature": + err = unpopulate(val, "Signature", &a.Signature) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgreementResource. +func (a AgreementResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementResource. +func (a *AgreementResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgreementResourceListResponse. +func (a AgreementResourceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementResourceListResponse. +func (a *AgreementResourceListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponseBody. +func (e ErrorResponseBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseBody. +func (e *ErrorResponseBody) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OfferDetail. +func (o OfferDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "planId", o.PlanID) + populate(objectMap, "planName", o.PlanName) + populate(objectMap, "publisherId", o.PublisherID) + populate(objectMap, "status", o.Status) + populate(objectMap, "termUnit", o.TermUnit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OfferDetail. +func (o *OfferDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &o.PlanID) + delete(rawMsg, key) + case "planName": + err = unpopulate(val, "PlanName", &o.PlanName) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &o.PublisherID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + case "termUnit": + err = unpopulate(val, "TermUnit", &o.TermUnit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationResult. +func (o OperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResult. +func (o *OperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationResource. +func (o OrganizationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "location", o.Location) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "systemData", o.SystemData) + populate(objectMap, "tags", o.Tags) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationResource. +func (o *OrganizationResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &o.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &o.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &o.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationResourceListResult. +func (o OrganizationResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationResourceListResult. +func (o *OrganizationResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationResourceProperties. +func (o OrganizationResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdTime", o.CreatedTime) + populate(objectMap, "offerDetail", o.OfferDetail) + populate(objectMap, "organizationId", o.OrganizationID) + populate(objectMap, "provisioningState", o.ProvisioningState) + populate(objectMap, "ssoUrl", o.SsoURL) + populate(objectMap, "userDetail", o.UserDetail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationResourceProperties. +func (o *OrganizationResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdTime": + err = unpopulateTimeRFC3339(val, "CreatedTime", &o.CreatedTime) + delete(rawMsg, key) + case "offerDetail": + err = unpopulate(val, "OfferDetail", &o.OfferDetail) + delete(rawMsg, key) + case "organizationId": + err = unpopulate(val, "OrganizationID", &o.OrganizationID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) + delete(rawMsg, key) + case "ssoUrl": + err = unpopulate(val, "SsoURL", &o.SsoURL) + delete(rawMsg, key) + case "userDetail": + err = unpopulate(val, "UserDetail", &o.UserDetail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationResourceUpdate. +func (o OrganizationResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", o.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationResourceUpdate. +func (o *OrganizationResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &o.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderDefaultErrorResponse. +func (r ResourceProviderDefaultErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", r.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderDefaultErrorResponse. +func (r *ResourceProviderDefaultErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &r.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserDetail. +func (u UserDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "emailAddress", u.EmailAddress) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "lastName", u.LastName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserDetail. +func (u *UserDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "emailAddress": + err = unpopulate(val, "EmailAddress", &u.EmailAddress) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &u.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &u.LastName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_organization_client.go b/sdk/resourcemanager/confluent/armconfluent/organization_client.go similarity index 86% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_organization_client.go rename to sdk/resourcemanager/confluent/armconfluent/organization_client.go index 7a6f36cd885d..8e913db1bf7d 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_organization_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/organization_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // OrganizationClient contains the methods for the Organization group. // Don't use this type directly, use NewOrganizationClient() instead. type OrganizationClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOrganizationClient creates a new instance of OrganizationClient with the specified values. -// subscriptionID - Microsoft Azure subscription id -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Microsoft Azure subscription id +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOrganizationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OrganizationClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OrganizationClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OrganizationClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Organization resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - Resource group name -// organizationName - Organization resource name -// options - OrganizationClientBeginCreateOptions contains the optional parameters for the OrganizationClient.BeginCreate -// method. +// - resourceGroupName - Resource group name +// - organizationName - Organization resource name +// - options - OrganizationClientBeginCreateOptions contains the optional parameters for the OrganizationClient.BeginCreate +// method. func (client *OrganizationClient) BeginCreate(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientBeginCreateOptions) (*runtime.Poller[OrganizationClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, organizationName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[OrganizationClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[OrganizationClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OrganizationClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Organization resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *OrganizationClient) create(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, organizationName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -108,7 +100,7 @@ func (client *OrganizationClient) createCreateRequest(ctx context.Context, resou return nil, errors.New("parameter organizationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -124,34 +116,36 @@ func (client *OrganizationClient) createCreateRequest(ctx context.Context, resou // BeginDelete - Delete Organization resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - Resource group name -// organizationName - Organization resource name -// options - OrganizationClientBeginDeleteOptions contains the optional parameters for the OrganizationClient.BeginDelete -// method. +// - resourceGroupName - Resource group name +// - organizationName - Organization resource name +// - options - OrganizationClientBeginDeleteOptions contains the optional parameters for the OrganizationClient.BeginDelete +// method. func (client *OrganizationClient) BeginDelete(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientBeginDeleteOptions) (*runtime.Poller[OrganizationClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, organizationName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[OrganizationClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[OrganizationClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OrganizationClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete Organization resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 func (client *OrganizationClient) deleteOperation(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, organizationName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -176,7 +170,7 @@ func (client *OrganizationClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter organizationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -189,16 +183,17 @@ func (client *OrganizationClient) deleteCreateRequest(ctx context.Context, resou // Get - Get the properties of a specific Organization resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - Resource group name -// organizationName - Organization resource name -// options - OrganizationClientGetOptions contains the optional parameters for the OrganizationClient.Get method. +// - resourceGroupName - Resource group name +// - organizationName - Organization resource name +// - options - OrganizationClientGetOptions contains the optional parameters for the OrganizationClient.Get method. func (client *OrganizationClient) Get(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientGetOptions) (OrganizationClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, organizationName, options) if err != nil { return OrganizationClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationClientGetResponse{}, err } @@ -223,7 +218,7 @@ func (client *OrganizationClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter organizationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -244,11 +239,11 @@ func (client *OrganizationClient) getHandleResponse(resp *http.Response) (Organi } // NewListByResourceGroupPager - List all Organizations under the specified resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - Resource group name -// options - OrganizationClientListByResourceGroupOptions contains the optional parameters for the OrganizationClient.ListByResourceGroup -// method. +// - resourceGroupName - Resource group name +// - options - OrganizationClientListByResourceGroupOptions contains the optional parameters for the OrganizationClient.NewListByResourceGroupPager +// method. func (client *OrganizationClient) NewListByResourceGroupPager(resourceGroupName string, options *OrganizationClientListByResourceGroupOptions) *runtime.Pager[OrganizationClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[OrganizationClientListByResourceGroupResponse]{ More: func(page OrganizationClientListByResourceGroupResponse) bool { @@ -265,7 +260,7 @@ func (client *OrganizationClient) NewListByResourceGroupPager(resourceGroupName if err != nil { return OrganizationClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationClientListByResourceGroupResponse{}, err } @@ -288,7 +283,7 @@ func (client *OrganizationClient) listByResourceGroupCreateRequest(ctx context.C return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -309,10 +304,10 @@ func (client *OrganizationClient) listByResourceGroupHandleResponse(resp *http.R } // NewListBySubscriptionPager - List all organizations under the specified subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - OrganizationClientListBySubscriptionOptions contains the optional parameters for the OrganizationClient.ListBySubscription -// method. +// - options - OrganizationClientListBySubscriptionOptions contains the optional parameters for the OrganizationClient.NewListBySubscriptionPager +// method. func (client *OrganizationClient) NewListBySubscriptionPager(options *OrganizationClientListBySubscriptionOptions) *runtime.Pager[OrganizationClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[OrganizationClientListBySubscriptionResponse]{ More: func(page OrganizationClientListBySubscriptionResponse) bool { @@ -329,7 +324,7 @@ func (client *OrganizationClient) NewListBySubscriptionPager(options *Organizati if err != nil { return OrganizationClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationClientListBySubscriptionResponse{}, err } @@ -348,7 +343,7 @@ func (client *OrganizationClient) listBySubscriptionCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -370,16 +365,17 @@ func (client *OrganizationClient) listBySubscriptionHandleResponse(resp *http.Re // Update - Update Organization resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - Resource group name -// organizationName - Organization resource name -// options - OrganizationClientUpdateOptions contains the optional parameters for the OrganizationClient.Update method. +// - resourceGroupName - Resource group name +// - organizationName - Organization resource name +// - options - OrganizationClientUpdateOptions contains the optional parameters for the OrganizationClient.Update method. func (client *OrganizationClient) Update(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationClientUpdateOptions) (OrganizationClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, organizationName, options) if err != nil { return OrganizationClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationClientUpdateResponse{}, err } @@ -404,7 +400,7 @@ func (client *OrganizationClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter organizationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go new file mode 100644 index 000000000000..7b4f0a66320a --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/organization_client_example_test.go @@ -0,0 +1,350 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfluent_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_ListBySubscription.json +func ExampleOrganizationClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OrganizationResourceListResult = armconfluent.OrganizationResourceListResult{ + // Value: []*armconfluent.OrganizationResource{ + // { + // Name: to.Ptr("myOrganizations"), + // Type: to.Ptr("Microsoft.Confluent/organizations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Confluent/organizations/myOrganizations"), + // Location: to.Ptr("West US"), + // Properties: &armconfluent.OrganizationResourceProperties{ + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // OfferDetail: &armconfluent.OfferDetail{ + // ID: to.Ptr("string"), + // PlanID: to.Ptr("string"), + // PlanName: to.Ptr("string"), + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // }, + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_ListByResourceGroup.json +func ExampleOrganizationClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationClient().NewListByResourceGroupPager("myResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OrganizationResourceListResult = armconfluent.OrganizationResourceListResult{ + // Value: []*armconfluent.OrganizationResource{ + // { + // Name: to.Ptr("myOrganizations"), + // Type: to.Ptr("Microsoft.Confluent/organizations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Confluent/organizations/myOrganizations"), + // Location: to.Ptr("West US"), + // Properties: &armconfluent.OrganizationResourceProperties{ + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // OfferDetail: &armconfluent.OfferDetail{ + // ID: to.Ptr("string"), + // PlanID: to.Ptr("string"), + // PlanName: to.Ptr("string"), + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // }, + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Get.json +func ExampleOrganizationClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOrganizationClient().Get(ctx, "myResourceGroup", "myOrganization", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OrganizationResource = armconfluent.OrganizationResource{ + // Name: to.Ptr("myOrganization"), + // Type: to.Ptr("Microsoft.Confluent/organizations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Confluent/organizations/myOrganization"), + // Location: to.Ptr("West US"), + // Properties: &armconfluent.OrganizationResourceProperties{ + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // OfferDetail: &armconfluent.OfferDetail{ + // ID: to.Ptr("string"), + // PlanID: to.Ptr("string"), + // PlanName: to.Ptr("string"), + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // }, + // }, + // SystemData: &armconfluent.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Create.json +func ExampleOrganizationClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationClient().BeginCreate(ctx, "myResourceGroup", "myOrganization", &armconfluent.OrganizationClientBeginCreateOptions{Body: &armconfluent.OrganizationResource{ + Location: to.Ptr("West US"), + Properties: &armconfluent.OrganizationResourceProperties{ + OfferDetail: &armconfluent.OfferDetail{ + ID: to.Ptr("string"), + PlanID: to.Ptr("string"), + PlanName: to.Ptr("string"), + PublisherID: to.Ptr("string"), + TermUnit: to.Ptr("string"), + }, + UserDetail: &armconfluent.UserDetail{ + EmailAddress: to.Ptr("contoso@microsoft.com"), + FirstName: to.Ptr("string"), + LastName: to.Ptr("string"), + }, + }, + Tags: map[string]*string{ + "Environment": to.Ptr("Dev"), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OrganizationResource = armconfluent.OrganizationResource{ + // Name: to.Ptr("myOrganization"), + // Type: to.Ptr("Microsoft.Confluent/organizations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Confluent/organizations/myOrganization"), + // Location: to.Ptr("West US"), + // Properties: &armconfluent.OrganizationResourceProperties{ + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // OfferDetail: &armconfluent.OfferDetail{ + // ID: to.Ptr("string"), + // PlanID: to.Ptr("string"), + // PlanName: to.Ptr("string"), + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // }, + // }, + // SystemData: &armconfluent.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Update.json +func ExampleOrganizationClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOrganizationClient().Update(ctx, "myResourceGroup", "myOrganization", &armconfluent.OrganizationClientUpdateOptions{Body: &armconfluent.OrganizationResourceUpdate{ + Tags: map[string]*string{ + "client": to.Ptr("dev-client"), + "env": to.Ptr("dev"), + }, + }, + }) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OrganizationResource = armconfluent.OrganizationResource{ + // Name: to.Ptr("myOrganization"), + // Type: to.Ptr("Microsoft.Confluent/organizations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Confluent/organizations/myOrganization"), + // Location: to.Ptr("West US"), + // Properties: &armconfluent.OrganizationResourceProperties{ + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // OfferDetail: &armconfluent.OfferDetail{ + // ID: to.Ptr("string"), + // PlanID: to.Ptr("string"), + // PlanName: to.Ptr("string"), + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // EmailAddress: to.Ptr("contoso@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // }, + // }, + // SystemData: &armconfluent.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armconfluent.CreatedByTypeUser), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Delete.json +func ExampleOrganizationClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationClient().BeginDelete(ctx, "myResourceGroup", "myOrganization", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_organizationoperations_client.go b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client.go similarity index 78% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_organizationoperations_client.go rename to sdk/resourcemanager/confluent/armconfluent/organizationoperations_client.go index 1b182289b06a..9d86a7a613ec 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_organizationoperations_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,37 +21,28 @@ import ( // OrganizationOperationsClient contains the methods for the OrganizationOperations group. // Don't use this type directly, use NewOrganizationOperationsClient() instead. type OrganizationOperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOrganizationOperationsClient creates a new instance of OrganizationOperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOrganizationOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OrganizationOperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OrganizationOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OrganizationOperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List all operations provided by Microsoft.Confluent. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// options - OrganizationOperationsClientListOptions contains the optional parameters for the OrganizationOperationsClient.List -// method. +// - options - OrganizationOperationsClientListOptions contains the optional parameters for the OrganizationOperationsClient.NewListPager +// method. func (client *OrganizationOperationsClient) NewListPager(options *OrganizationOperationsClientListOptions) *runtime.Pager[OrganizationOperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OrganizationOperationsClientListResponse]{ More: func(page OrganizationOperationsClientListResponse) bool { @@ -69,7 +59,7 @@ func (client *OrganizationOperationsClient) NewListPager(options *OrganizationOp if err != nil { return OrganizationOperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OrganizationOperationsClientListResponse{}, err } @@ -84,7 +74,7 @@ func (client *OrganizationOperationsClient) NewListPager(options *OrganizationOp // listCreateRequest creates the List request. func (client *OrganizationOperationsClient) listCreateRequest(ctx context.Context, options *OrganizationOperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Confluent/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go new file mode 100644 index 000000000000..9391b9916423 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/organizationoperations_client_example_test.go @@ -0,0 +1,76 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfluent_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/OrganizationOperations_List.json +func ExampleOrganizationOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armconfluent.OperationListResult{ + // Value: []*armconfluent.OperationResult{ + // { + // Name: to.Ptr("Microsoft.Confluent/organizations/Read"), + // Display: &armconfluent.OperationDisplay{ + // Description: to.Ptr("Read organization"), + // Operation: to.Ptr("Get/List organization resources"), + // Provider: to.Ptr("Microsoft.Confluent"), + // Resource: to.Ptr("organizations"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Confluent/organizations/Write"), + // Display: &armconfluent.OperationDisplay{ + // Description: to.Ptr("Write organization"), + // Operation: to.Ptr("Create/Update organization resources"), + // Provider: to.Ptr("Microsoft.Confluent"), + // Resource: to.Ptr("organizations"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.Confluent/organizations/Delete"), + // Display: &armconfluent.OperationDisplay{ + // Description: to.Ptr("Delete organization"), + // Operation: to.Ptr("Delete organization resources"), + // Provider: to.Ptr("Microsoft.Confluent"), + // Resource: to.Ptr("organizations"), + // }, + // IsDataAction: to.Ptr(false), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_response_types.go b/sdk/resourcemanager/confluent/armconfluent/response_types.go similarity index 85% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_response_types.go rename to sdk/resourcemanager/confluent/armconfluent/response_types.go index 361d2092e9c7..2df73e4e379e 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_response_types.go +++ b/sdk/resourcemanager/confluent/armconfluent/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent @@ -13,17 +14,17 @@ type MarketplaceAgreementsClientCreateResponse struct { AgreementResource } -// MarketplaceAgreementsClientListResponse contains the response from method MarketplaceAgreementsClient.List. +// MarketplaceAgreementsClientListResponse contains the response from method MarketplaceAgreementsClient.NewListPager. type MarketplaceAgreementsClientListResponse struct { AgreementResourceListResponse } -// OrganizationClientCreateResponse contains the response from method OrganizationClient.Create. +// OrganizationClientCreateResponse contains the response from method OrganizationClient.BeginCreate. type OrganizationClientCreateResponse struct { OrganizationResource } -// OrganizationClientDeleteResponse contains the response from method OrganizationClient.Delete. +// OrganizationClientDeleteResponse contains the response from method OrganizationClient.BeginDelete. type OrganizationClientDeleteResponse struct { // placeholder for future response values } @@ -33,12 +34,12 @@ type OrganizationClientGetResponse struct { OrganizationResource } -// OrganizationClientListByResourceGroupResponse contains the response from method OrganizationClient.ListByResourceGroup. +// OrganizationClientListByResourceGroupResponse contains the response from method OrganizationClient.NewListByResourceGroupPager. type OrganizationClientListByResourceGroupResponse struct { OrganizationResourceListResult } -// OrganizationClientListBySubscriptionResponse contains the response from method OrganizationClient.ListBySubscription. +// OrganizationClientListBySubscriptionResponse contains the response from method OrganizationClient.NewListBySubscriptionPager. type OrganizationClientListBySubscriptionResponse struct { OrganizationResourceListResult } @@ -48,7 +49,7 @@ type OrganizationClientUpdateResponse struct { OrganizationResource } -// OrganizationOperationsClientListResponse contains the response from method OrganizationOperationsClient.List. +// OrganizationOperationsClientListResponse contains the response from method OrganizationOperationsClient.NewListPager. type OrganizationOperationsClientListResponse struct { OperationListResult } diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_time_rfc3339.go b/sdk/resourcemanager/confluent/armconfluent/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/confluent/armconfluent/time_rfc3339.go index 080302fae9a8..281c092bc487 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/confluent/armconfluent/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_validations_client.go b/sdk/resourcemanager/confluent/armconfluent/validations_client.go similarity index 78% rename from sdk/resourcemanager/confluent/armconfluent/zz_generated_validations_client.go rename to sdk/resourcemanager/confluent/armconfluent/validations_client.go index 4dbc64787a9d..f34ddb8003d0 100644 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_validations_client.go +++ b/sdk/resourcemanager/confluent/armconfluent/validations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armconfluent @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // ValidationsClient contains the methods for the Validations group. // Don't use this type directly, use NewValidationsClient() instead. type ValidationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewValidationsClient creates a new instance of ValidationsClient with the specified values. -// subscriptionID - Microsoft Azure subscription id -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Microsoft Azure subscription id +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewValidationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ValidationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ValidationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ValidationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // ValidateOrganization - Organization Validate proxy resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01 -// resourceGroupName - Resource group name -// organizationName - Organization resource name -// body - Organization resource model -// options - ValidationsClientValidateOrganizationOptions contains the optional parameters for the ValidationsClient.ValidateOrganization -// method. +// - resourceGroupName - Resource group name +// - organizationName - Organization resource name +// - body - Organization resource model +// - options - ValidationsClientValidateOrganizationOptions contains the optional parameters for the ValidationsClient.ValidateOrganization +// method. func (client *ValidationsClient) ValidateOrganization(ctx context.Context, resourceGroupName string, organizationName string, body OrganizationResource, options *ValidationsClientValidateOrganizationOptions) (ValidationsClientValidateOrganizationResponse, error) { req, err := client.validateOrganizationCreateRequest(ctx, resourceGroupName, organizationName, body, options) if err != nil { return ValidationsClientValidateOrganizationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ValidationsClientValidateOrganizationResponse{}, err } @@ -92,7 +83,7 @@ func (client *ValidationsClient) validateOrganizationCreateRequest(ctx context.C return nil, errors.New("parameter organizationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go b/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go new file mode 100644 index 000000000000..9c707566b136 --- /dev/null +++ b/sdk/resourcemanager/confluent/armconfluent/validations_client_example_test.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armconfluent_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Validations_ValidateOrganizations.json +func ExampleValidationsClient_ValidateOrganization() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armconfluent.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewValidationsClient().ValidateOrganization(ctx, "myResourceGroup", "myOrganization", armconfluent.OrganizationResource{ + Location: to.Ptr("West US"), + Properties: &armconfluent.OrganizationResourceProperties{ + OfferDetail: &armconfluent.OfferDetail{ + ID: to.Ptr("string"), + PlanID: to.Ptr("string"), + PlanName: to.Ptr("string"), + PublisherID: to.Ptr("string"), + TermUnit: to.Ptr("string"), + }, + UserDetail: &armconfluent.UserDetail{ + EmailAddress: to.Ptr("abc@microsoft.com"), + FirstName: to.Ptr("string"), + LastName: to.Ptr("string"), + }, + }, + Tags: map[string]*string{ + "Environment": to.Ptr("Dev"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OrganizationResource = armconfluent.OrganizationResource{ + // Name: to.Ptr("myOrganization"), + // Type: to.Ptr("Microsoft.Confluent/organizations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Confluent/organizations/myOrganization"), + // Location: to.Ptr("West US"), + // Properties: &armconfluent.OrganizationResourceProperties{ + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-09T14:28:47.284Z"); return t}()), + // OfferDetail: &armconfluent.OfferDetail{ + // ID: to.Ptr("string"), + // PlanID: to.Ptr("string"), + // PlanName: to.Ptr("string"), + // PublisherID: to.Ptr("string"), + // Status: to.Ptr(armconfluent.SaaSOfferStatusStarted), + // TermUnit: to.Ptr("string"), + // }, + // OrganizationID: to.Ptr("string"), + // ProvisioningState: to.Ptr(armconfluent.ProvisionStateSucceeded), + // SsoURL: to.Ptr("string"), + // UserDetail: &armconfluent.UserDetail{ + // EmailAddress: to.Ptr("abc@microsoft.com"), + // FirstName: to.Ptr("string"), + // LastName: to.Ptr("string"), + // }, + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } +} diff --git a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_marketplaceagreements_client_test.go b/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_marketplaceagreements_client_test.go deleted file mode 100644 index 117ed5e4d299..000000000000 --- a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_marketplaceagreements_client_test.go +++ /dev/null @@ -1,61 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfluent_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/MarketplaceAgreements_List.json -func ExampleMarketplaceAgreementsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewMarketplaceAgreementsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/MarketplaceAgreements_Create.json -func ExampleMarketplaceAgreementsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewMarketplaceAgreementsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - &armconfluent.MarketplaceAgreementsClientCreateOptions{Body: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organization_client_test.go b/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organization_client_test.go deleted file mode 100644 index badb368fc9e9..000000000000 --- a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organization_client_test.go +++ /dev/null @@ -1,187 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfluent_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_ListBySubscription.json -func ExampleOrganizationClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewOrganizationClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_ListByResourceGroup.json -func ExampleOrganizationClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewOrganizationClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myResourceGroup", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Get.json -func ExampleOrganizationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewOrganizationClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myOrganization", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Create.json -func ExampleOrganizationClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewOrganizationClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "myResourceGroup", - "myOrganization", - &armconfluent.OrganizationClientBeginCreateOptions{Body: &armconfluent.OrganizationResource{ - Location: to.Ptr("West US"), - Properties: &armconfluent.OrganizationResourceProperties{ - OfferDetail: &armconfluent.OfferDetail{ - ID: to.Ptr("string"), - PlanID: to.Ptr("string"), - PlanName: to.Ptr("string"), - PublisherID: to.Ptr("string"), - TermUnit: to.Ptr("string"), - }, - UserDetail: &armconfluent.UserDetail{ - EmailAddress: to.Ptr("contoso@microsoft.com"), - FirstName: to.Ptr("string"), - LastName: to.Ptr("string"), - }, - }, - Tags: map[string]*string{ - "Environment": to.Ptr("Dev"), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Update.json -func ExampleOrganizationClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewOrganizationClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "myResourceGroup", - "myOrganization", - &armconfluent.OrganizationClientUpdateOptions{Body: &armconfluent.OrganizationResourceUpdate{ - Tags: map[string]*string{ - "client": to.Ptr("dev-client"), - "env": to.Ptr("dev"), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Organization_Delete.json -func ExampleOrganizationClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewOrganizationClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "myResourceGroup", - "myOrganization", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organizationoperations_client_test.go b/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organizationoperations_client_test.go deleted file mode 100644 index 1c4f8b1fd50a..000000000000 --- a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_organizationoperations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfluent_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/OrganizationOperations_List.json -func ExampleOrganizationOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewOrganizationOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_validations_client_test.go b/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_validations_client_test.go deleted file mode 100644 index 8b4bc5ef7840..000000000000 --- a/sdk/resourcemanager/confluent/armconfluent/ze_generated_example_validations_client_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfluent_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/confluent/armconfluent" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/confluent/resource-manager/Microsoft.Confluent/stable/2021-12-01/examples/Validations_ValidateOrganizations.json -func ExampleValidationsClient_ValidateOrganization() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armconfluent.NewValidationsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ValidateOrganization(ctx, - "myResourceGroup", - "myOrganization", - armconfluent.OrganizationResource{ - Location: to.Ptr("West US"), - Properties: &armconfluent.OrganizationResourceProperties{ - OfferDetail: &armconfluent.OfferDetail{ - ID: to.Ptr("string"), - PlanID: to.Ptr("string"), - PlanName: to.Ptr("string"), - PublisherID: to.Ptr("string"), - TermUnit: to.Ptr("string"), - }, - UserDetail: &armconfluent.UserDetail{ - EmailAddress: to.Ptr("abc@microsoft.com"), - FirstName: to.Ptr("string"), - LastName: to.Ptr("string"), - }, - }, - Tags: map[string]*string{ - "Environment": to.Ptr("Dev"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/confluent/armconfluent/zz_generated_models_serde.go b/sdk/resourcemanager/confluent/armconfluent/zz_generated_models_serde.go deleted file mode 100644 index 8a4c317fefe5..000000000000 --- a/sdk/resourcemanager/confluent/armconfluent/zz_generated_models_serde.go +++ /dev/null @@ -1,205 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armconfluent - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AgreementProperties. -func (a AgreementProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accepted", a.Accepted) - populate(objectMap, "licenseTextLink", a.LicenseTextLink) - populate(objectMap, "plan", a.Plan) - populate(objectMap, "privacyPolicyLink", a.PrivacyPolicyLink) - populate(objectMap, "product", a.Product) - populate(objectMap, "publisher", a.Publisher) - populateTimeRFC3339(objectMap, "retrieveDatetime", a.RetrieveDatetime) - populate(objectMap, "signature", a.Signature) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AgreementProperties. -func (a *AgreementProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "accepted": - err = unpopulate(val, "Accepted", &a.Accepted) - delete(rawMsg, key) - case "licenseTextLink": - err = unpopulate(val, "LicenseTextLink", &a.LicenseTextLink) - delete(rawMsg, key) - case "plan": - err = unpopulate(val, "Plan", &a.Plan) - delete(rawMsg, key) - case "privacyPolicyLink": - err = unpopulate(val, "PrivacyPolicyLink", &a.PrivacyPolicyLink) - delete(rawMsg, key) - case "product": - err = unpopulate(val, "Product", &a.Product) - delete(rawMsg, key) - case "publisher": - err = unpopulate(val, "Publisher", &a.Publisher) - delete(rawMsg, key) - case "retrieveDatetime": - err = unpopulateTimeRFC3339(val, "RetrieveDatetime", &a.RetrieveDatetime) - delete(rawMsg, key) - case "signature": - err = unpopulate(val, "Signature", &a.Signature) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type OrganizationResource. -func (o OrganizationResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", o.ID) - populate(objectMap, "location", o.Location) - populate(objectMap, "name", o.Name) - populate(objectMap, "properties", o.Properties) - populate(objectMap, "systemData", o.SystemData) - populate(objectMap, "tags", o.Tags) - populate(objectMap, "type", o.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type OrganizationResourceProperties. -func (o OrganizationResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdTime", o.CreatedTime) - populate(objectMap, "offerDetail", o.OfferDetail) - populate(objectMap, "organizationId", o.OrganizationID) - populate(objectMap, "provisioningState", o.ProvisioningState) - populate(objectMap, "ssoUrl", o.SsoURL) - populate(objectMap, "userDetail", o.UserDetail) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationResourceProperties. -func (o *OrganizationResourceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &o.CreatedTime) - delete(rawMsg, key) - case "offerDetail": - err = unpopulate(val, "OfferDetail", &o.OfferDetail) - delete(rawMsg, key) - case "organizationId": - err = unpopulate(val, "OrganizationID", &o.OrganizationID) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) - delete(rawMsg, key) - case "ssoUrl": - err = unpopulate(val, "SsoURL", &o.SsoURL) - delete(rawMsg, key) - case "userDetail": - err = unpopulate(val, "UserDetail", &o.UserDetail) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type OrganizationResourceUpdate. -func (o OrganizationResourceUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", o.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md b/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md index ede910c256da..2aabda73c05d 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md @@ -1,5 +1,16 @@ # Release History +## 0.2.0 (2023-03-28) +### Breaking Changes + +- Struct `Condition` has been removed +- Struct `MachineExtensionInstanceView` has been removed + +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.1.0 (2022-08-09) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.1.0, which contains breaking changes. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/README.md b/sdk/resourcemanager/connectedvmware/armconnectedvmware/README.md index a994fcae84b4..09a8e4d39f47 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/README.md +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Arc VMware Management modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Arc VMware Management module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armconnectedvmware.NewVirtualMachineTemplatesClient(, cred, nil) +clientFactory, err := armconnectedvmware.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armconnectedvmware.NewVirtualMachineTemplatesClient(, cred, &options) +clientFactory, err := armconnectedvmware.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewVirtualMachinesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md b/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md index 52d800235dd0..26f683c59d31 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 +module-version: 0.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go new file mode 100644 index 000000000000..3261996ebefe --- /dev/null +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go @@ -0,0 +1,112 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. + +package armconnectedvmware + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualMachinesClient() *VirtualMachinesClient { + subClient, _ := NewVirtualMachinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourcePoolsClient() *ResourcePoolsClient { + subClient, _ := NewResourcePoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClustersClient() *ClustersClient { + subClient, _ := NewClustersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHostsClient() *HostsClient { + subClient, _ := NewHostsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDatastoresClient() *DatastoresClient { + subClient, _ := NewDatastoresClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVCentersClient() *VCentersClient { + subClient, _ := NewVCentersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualMachineTemplatesClient() *VirtualMachineTemplatesClient { + subClient, _ := NewVirtualMachineTemplatesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualNetworksClient() *VirtualNetworksClient { + subClient, _ := NewVirtualNetworksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewInventoryItemsClient() *InventoryItemsClient { + subClient, _ := NewInventoryItemsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHybridIdentityMetadataClient() *HybridIdentityMetadataClient { + subClient, _ := NewHybridIdentityMetadataClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMachineExtensionsClient() *MachineExtensionsClient { + subClient, _ := NewMachineExtensionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGuestAgentsClient() *GuestAgentsClient { + subClient, _ := NewGuestAgentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go index 145df9dfe317..2daa5ab0c1a1 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,65 +33,58 @@ import ( // ClustersClient contains the methods for the Clusters group. // Don't use this type directly, use NewClustersClient() instead. type ClustersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewClustersClient creates a new instance of ClustersClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClustersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClustersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ClustersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ClustersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update cluster. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// clusterName - Name of the cluster. -// body - Request payload. -// options - ClustersClientBeginCreateOptions contains the optional parameters for the ClustersClient.BeginCreate method. +// - resourceGroupName - The Resource Group Name. +// - clusterName - Name of the cluster. +// - body - Request payload. +// - options - ClustersClientBeginCreateOptions contains the optional parameters for the ClustersClient.BeginCreate method. func (client *ClustersClient) BeginCreate(ctx context.Context, resourceGroupName string, clusterName string, body Cluster, options *ClustersClientBeginCreateOptions) (*runtime.Poller[ClustersClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, clusterName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ClustersClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ClustersClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClustersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update cluster. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *ClustersClient) create(ctx context.Context, resourceGroupName string, clusterName string, body Cluster, options *ClustersClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, clusterName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -118,7 +109,7 @@ func (client *ClustersClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter clusterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -131,31 +122,33 @@ func (client *ClustersClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Implements cluster DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// clusterName - Name of the cluster. -// options - ClustersClientBeginDeleteOptions contains the optional parameters for the ClustersClient.BeginDelete method. +// - resourceGroupName - The Resource Group Name. +// - clusterName - Name of the cluster. +// - options - ClustersClientBeginDeleteOptions contains the optional parameters for the ClustersClient.BeginDelete method. func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginDeleteOptions) (*runtime.Poller[ClustersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, options) if err != nil { return nil, err } - return runtime.NewPoller[ClustersClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ClustersClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ClustersClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClustersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements cluster DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *ClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +173,7 @@ func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter clusterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -196,16 +189,17 @@ func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Implements cluster GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// clusterName - Name of the cluster. -// options - ClustersClientGetOptions contains the optional parameters for the ClustersClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - clusterName - Name of the cluster. +// - options - ClustersClientGetOptions contains the optional parameters for the ClustersClient.Get method. func (client *ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientGetOptions) (ClustersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return ClustersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClustersClientGetResponse{}, err } @@ -230,7 +224,7 @@ func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter clusterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -251,9 +245,9 @@ func (client *ClustersClient) getHandleResponse(resp *http.Response) (ClustersCl } // NewListPager - List of clusters in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - ClustersClientListOptions contains the optional parameters for the ClustersClient.List method. +// - options - ClustersClientListOptions contains the optional parameters for the ClustersClient.NewListPager method. func (client *ClustersClient) NewListPager(options *ClustersClientListOptions) *runtime.Pager[ClustersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClustersClientListResponse]{ More: func(page ClustersClientListResponse) bool { @@ -270,7 +264,7 @@ func (client *ClustersClient) NewListPager(options *ClustersClientListOptions) * if err != nil { return ClustersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClustersClientListResponse{}, err } @@ -289,7 +283,7 @@ func (client *ClustersClient) listCreateRequest(ctx context.Context, options *Cl return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -310,11 +304,11 @@ func (client *ClustersClient) listHandleResponse(resp *http.Response) (ClustersC } // NewListByResourceGroupPager - List of clusters in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.NewListByResourceGroupPager +// method. func (client *ClustersClient) NewListByResourceGroupPager(resourceGroupName string, options *ClustersClientListByResourceGroupOptions) *runtime.Pager[ClustersClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ClustersClientListByResourceGroupResponse]{ More: func(page ClustersClientListByResourceGroupResponse) bool { @@ -331,7 +325,7 @@ func (client *ClustersClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return ClustersClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClustersClientListByResourceGroupResponse{}, err } @@ -354,7 +348,7 @@ func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -376,17 +370,18 @@ func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - API to update certain properties of the cluster resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// clusterName - Name of the cluster. -// body - Resource properties to update. -// options - ClustersClientUpdateOptions contains the optional parameters for the ClustersClient.Update method. +// - resourceGroupName - The Resource Group Name. +// - clusterName - Name of the cluster. +// - body - Resource properties to update. +// - options - ClustersClientUpdateOptions contains the optional parameters for the ClustersClient.Update method. func (client *ClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, body ResourcePatch, options *ClustersClientUpdateOptions) (ClustersClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, body, options) if err != nil { return ClustersClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClustersClientUpdateResponse{}, err } @@ -411,7 +406,7 @@ func (client *ClustersClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter clusterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go index 342d842bedb3..3093b39c4786 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateCluster.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateCluster.json func ExampleClustersClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewClustersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "HRCluster", armconnectedvmware.Cluster{ + poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "testrg", "HRCluster", armconnectedvmware.Cluster{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -46,41 +55,73 @@ func ExampleClustersClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Cluster = armconnectedvmware.Cluster{ + // Name: to.Ptr("HRCluster"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ClusterProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetCluster.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetCluster.json func ExampleClustersClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewClustersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "HRCluster", nil) + res, err := clientFactory.NewClustersClient().Get(ctx, "testrg", "HRCluster", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Cluster = armconnectedvmware.Cluster{ + // Name: to.Ptr("HRCluster"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ClusterProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateCluster.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateCluster.json func ExampleClustersClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewClustersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "testrg", "HRCluster", armconnectedvmware.ResourcePatch{ + res, err := clientFactory.NewClustersClient().Update(ctx, "testrg", "HRCluster", armconnectedvmware.ResourcePatch{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -89,22 +130,42 @@ func ExampleClustersClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Cluster = armconnectedvmware.Cluster{ + // Name: to.Ptr("HRCluster"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ClusterProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteCluster.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteCluster.json func ExampleClustersClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewClustersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "HRCluster", &armconnectedvmware.ClustersClientBeginDeleteOptions{Force: nil}) + poller, err := clientFactory.NewClustersClient().BeginDelete(ctx, "testrg", "HRCluster", &armconnectedvmware.ClustersClientBeginDeleteOptions{Force: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -114,50 +175,88 @@ func ExampleClustersClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListClusters.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListClusters.json func ExampleClustersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewClustersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewClustersClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ClustersList = armconnectedvmware.ClustersList{ + // Value: []*armconnectedvmware.Cluster{ + // { + // Name: to.Ptr("HRCluster"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ClusterProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListClustersByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListClustersByResourceGroup.json func ExampleClustersClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewClustersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewClustersClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ClustersList = armconnectedvmware.ClustersList{ + // Value: []*armconnectedvmware.Cluster{ + // { + // Name: to.Ptr("HRCluster"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ClusterProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go index 6c3a13c0d46a..c15264ead078 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go @@ -19,7 +19,7 @@ package armconnectedvmware const ( moduleName = "armconnectedvmware" - moduleVersion = "v0.1.0" + moduleVersion = "v0.2.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go index bac3866960c8..254dedfb7f77 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,65 +33,58 @@ import ( // DatastoresClient contains the methods for the Datastores group. // Don't use this type directly, use NewDatastoresClient() instead. type DatastoresClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDatastoresClient creates a new instance of DatastoresClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDatastoresClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DatastoresClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DatastoresClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DatastoresClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update datastore. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// datastoreName - Name of the datastore. -// body - Request payload. -// options - DatastoresClientBeginCreateOptions contains the optional parameters for the DatastoresClient.BeginCreate method. +// - resourceGroupName - The Resource Group Name. +// - datastoreName - Name of the datastore. +// - body - Request payload. +// - options - DatastoresClientBeginCreateOptions contains the optional parameters for the DatastoresClient.BeginCreate method. func (client *DatastoresClient) BeginCreate(ctx context.Context, resourceGroupName string, datastoreName string, body Datastore, options *DatastoresClientBeginCreateOptions) (*runtime.Poller[DatastoresClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, datastoreName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DatastoresClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatastoresClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[DatastoresClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatastoresClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update datastore. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *DatastoresClient) create(ctx context.Context, resourceGroupName string, datastoreName string, body Datastore, options *DatastoresClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, datastoreName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -118,7 +109,7 @@ func (client *DatastoresClient) createCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter datastoreName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{datastoreName}", url.PathEscape(datastoreName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -131,31 +122,33 @@ func (client *DatastoresClient) createCreateRequest(ctx context.Context, resourc // BeginDelete - Implements datastore DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// datastoreName - Name of the datastore. -// options - DatastoresClientBeginDeleteOptions contains the optional parameters for the DatastoresClient.BeginDelete method. +// - resourceGroupName - The Resource Group Name. +// - datastoreName - Name of the datastore. +// - options - DatastoresClientBeginDeleteOptions contains the optional parameters for the DatastoresClient.BeginDelete method. func (client *DatastoresClient) BeginDelete(ctx context.Context, resourceGroupName string, datastoreName string, options *DatastoresClientBeginDeleteOptions) (*runtime.Poller[DatastoresClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, datastoreName, options) if err != nil { return nil, err } - return runtime.NewPoller[DatastoresClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DatastoresClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DatastoresClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatastoresClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements datastore DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *DatastoresClient) deleteOperation(ctx context.Context, resourceGroupName string, datastoreName string, options *DatastoresClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, datastoreName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +173,7 @@ func (client *DatastoresClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter datastoreName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{datastoreName}", url.PathEscape(datastoreName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -196,16 +189,17 @@ func (client *DatastoresClient) deleteCreateRequest(ctx context.Context, resourc // Get - Implements datastore GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// datastoreName - Name of the datastore. -// options - DatastoresClientGetOptions contains the optional parameters for the DatastoresClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - datastoreName - Name of the datastore. +// - options - DatastoresClientGetOptions contains the optional parameters for the DatastoresClient.Get method. func (client *DatastoresClient) Get(ctx context.Context, resourceGroupName string, datastoreName string, options *DatastoresClientGetOptions) (DatastoresClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, datastoreName, options) if err != nil { return DatastoresClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatastoresClientGetResponse{}, err } @@ -230,7 +224,7 @@ func (client *DatastoresClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter datastoreName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{datastoreName}", url.PathEscape(datastoreName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -251,9 +245,9 @@ func (client *DatastoresClient) getHandleResponse(resp *http.Response) (Datastor } // NewListPager - List of datastores in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - DatastoresClientListOptions contains the optional parameters for the DatastoresClient.List method. +// - options - DatastoresClientListOptions contains the optional parameters for the DatastoresClient.NewListPager method. func (client *DatastoresClient) NewListPager(options *DatastoresClientListOptions) *runtime.Pager[DatastoresClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DatastoresClientListResponse]{ More: func(page DatastoresClientListResponse) bool { @@ -270,7 +264,7 @@ func (client *DatastoresClient) NewListPager(options *DatastoresClientListOption if err != nil { return DatastoresClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatastoresClientListResponse{}, err } @@ -289,7 +283,7 @@ func (client *DatastoresClient) listCreateRequest(ctx context.Context, options * return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -310,11 +304,11 @@ func (client *DatastoresClient) listHandleResponse(resp *http.Response) (Datasto } // NewListByResourceGroupPager - List of datastores in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - DatastoresClientListByResourceGroupOptions contains the optional parameters for the DatastoresClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - DatastoresClientListByResourceGroupOptions contains the optional parameters for the DatastoresClient.NewListByResourceGroupPager +// method. func (client *DatastoresClient) NewListByResourceGroupPager(resourceGroupName string, options *DatastoresClientListByResourceGroupOptions) *runtime.Pager[DatastoresClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[DatastoresClientListByResourceGroupResponse]{ More: func(page DatastoresClientListByResourceGroupResponse) bool { @@ -331,7 +325,7 @@ func (client *DatastoresClient) NewListByResourceGroupPager(resourceGroupName st if err != nil { return DatastoresClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatastoresClientListByResourceGroupResponse{}, err } @@ -354,7 +348,7 @@ func (client *DatastoresClient) listByResourceGroupCreateRequest(ctx context.Con return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -376,17 +370,18 @@ func (client *DatastoresClient) listByResourceGroupHandleResponse(resp *http.Res // Update - API to update certain properties of the datastore resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// datastoreName - Name of the datastore. -// body - Resource properties to update. -// options - DatastoresClientUpdateOptions contains the optional parameters for the DatastoresClient.Update method. +// - resourceGroupName - The Resource Group Name. +// - datastoreName - Name of the datastore. +// - body - Resource properties to update. +// - options - DatastoresClientUpdateOptions contains the optional parameters for the DatastoresClient.Update method. func (client *DatastoresClient) Update(ctx context.Context, resourceGroupName string, datastoreName string, body ResourcePatch, options *DatastoresClientUpdateOptions) (DatastoresClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, datastoreName, body, options) if err != nil { return DatastoresClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatastoresClientUpdateResponse{}, err } @@ -411,7 +406,7 @@ func (client *DatastoresClient) updateCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter datastoreName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{datastoreName}", url.PathEscape(datastoreName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go index 9fc668e5435d..a4df9a0ed3b7 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateDatastore.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateDatastore.json func ExampleDatastoresClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewDatastoresClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "HRDatastore", armconnectedvmware.Datastore{ + poller, err := clientFactory.NewDatastoresClient().BeginCreate(ctx, "testrg", "HRDatastore", armconnectedvmware.Datastore{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -46,41 +55,73 @@ func ExampleDatastoresClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Datastore = armconnectedvmware.Datastore{ + // Name: to.Ptr("HRDatastore"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.DatastoreProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetDatastore.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetDatastore.json func ExampleDatastoresClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewDatastoresClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "HRDatastore", nil) + res, err := clientFactory.NewDatastoresClient().Get(ctx, "testrg", "HRDatastore", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Datastore = armconnectedvmware.Datastore{ + // Name: to.Ptr("HRDatastore"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.DatastoreProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateDatastore.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateDatastore.json func ExampleDatastoresClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewDatastoresClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "testrg", "HRDatastore", armconnectedvmware.ResourcePatch{ + res, err := clientFactory.NewDatastoresClient().Update(ctx, "testrg", "HRDatastore", armconnectedvmware.ResourcePatch{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -89,22 +130,42 @@ func ExampleDatastoresClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Datastore = armconnectedvmware.Datastore{ + // Name: to.Ptr("HRDatastore"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.DatastoreProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteDatastore.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteDatastore.json func ExampleDatastoresClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewDatastoresClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "HRDatastore", &armconnectedvmware.DatastoresClientBeginDeleteOptions{Force: nil}) + poller, err := clientFactory.NewDatastoresClient().BeginDelete(ctx, "testrg", "HRDatastore", &armconnectedvmware.DatastoresClientBeginDeleteOptions{Force: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -114,50 +175,88 @@ func ExampleDatastoresClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListDatastores.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListDatastores.json func ExampleDatastoresClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewDatastoresClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewDatastoresClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DatastoresList = armconnectedvmware.DatastoresList{ + // Value: []*armconnectedvmware.Datastore{ + // { + // Name: to.Ptr("HRDatastore"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.DatastoreProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListDatastoresByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListDatastoresByResourceGroup.json func ExampleDatastoresClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewDatastoresClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewDatastoresClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DatastoresList = armconnectedvmware.DatastoresList{ + // Value: []*armconnectedvmware.Datastore{ + // { + // Name: to.Ptr("HRDatastore"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.DatastoreProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod index bc22cb3944e7..7bcb16f2fc98 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/arm go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go index 6b50aaf59226..b694e4615a63 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,66 +32,59 @@ import ( // GuestAgentsClient contains the methods for the GuestAgents group. // Don't use this type directly, use NewGuestAgentsClient() instead. type GuestAgentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewGuestAgentsClient creates a new instance of GuestAgentsClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGuestAgentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GuestAgentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".GuestAgentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GuestAgentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update GuestAgent. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// name - Name of the guestAgents. -// body - Request payload. -// options - GuestAgentsClientBeginCreateOptions contains the optional parameters for the GuestAgentsClient.BeginCreate method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - name - Name of the guestAgents. +// - body - Request payload. +// - options - GuestAgentsClientBeginCreateOptions contains the optional parameters for the GuestAgentsClient.BeginCreate method. func (client *GuestAgentsClient) BeginCreate(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, body GuestAgent, options *GuestAgentsClientBeginCreateOptions) (*runtime.Poller[GuestAgentsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, virtualMachineName, name, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[GuestAgentsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GuestAgentsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[GuestAgentsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[GuestAgentsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update GuestAgent. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *GuestAgentsClient) create(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, body GuestAgent, options *GuestAgentsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineName, name, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -122,7 +113,7 @@ func (client *GuestAgentsClient) createCreateRequest(ctx context.Context, resour return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -135,32 +126,34 @@ func (client *GuestAgentsClient) createCreateRequest(ctx context.Context, resour // BeginDelete - Implements GuestAgent DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// name - Name of the GuestAgent. -// options - GuestAgentsClientBeginDeleteOptions contains the optional parameters for the GuestAgentsClient.BeginDelete method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - name - Name of the GuestAgent. +// - options - GuestAgentsClientBeginDeleteOptions contains the optional parameters for the GuestAgentsClient.BeginDelete method. func (client *GuestAgentsClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, options *GuestAgentsClientBeginDeleteOptions) (*runtime.Poller[GuestAgentsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, virtualMachineName, name, options) if err != nil { return nil, err } - return runtime.NewPoller[GuestAgentsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[GuestAgentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[GuestAgentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[GuestAgentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements GuestAgent DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *GuestAgentsClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, options *GuestAgentsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, name, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -189,7 +182,7 @@ func (client *GuestAgentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -202,17 +195,18 @@ func (client *GuestAgentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Implements GuestAgent GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// name - Name of the GuestAgent. -// options - GuestAgentsClientGetOptions contains the optional parameters for the GuestAgentsClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - name - Name of the GuestAgent. +// - options - GuestAgentsClientGetOptions contains the optional parameters for the GuestAgentsClient.Get method. func (client *GuestAgentsClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, options *GuestAgentsClientGetOptions) (GuestAgentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, name, options) if err != nil { return GuestAgentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GuestAgentsClientGetResponse{}, err } @@ -241,7 +235,7 @@ func (client *GuestAgentsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -262,11 +256,12 @@ func (client *GuestAgentsClient) getHandleResponse(resp *http.Response) (GuestAg } // NewListByVMPager - Returns the list of GuestAgent of the given vm. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// options - GuestAgentsClientListByVMOptions contains the optional parameters for the GuestAgentsClient.ListByVM method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - options - GuestAgentsClientListByVMOptions contains the optional parameters for the GuestAgentsClient.NewListByVMPager +// method. func (client *GuestAgentsClient) NewListByVMPager(resourceGroupName string, virtualMachineName string, options *GuestAgentsClientListByVMOptions) *runtime.Pager[GuestAgentsClientListByVMResponse] { return runtime.NewPager(runtime.PagingHandler[GuestAgentsClientListByVMResponse]{ More: func(page GuestAgentsClientListByVMResponse) bool { @@ -283,7 +278,7 @@ func (client *GuestAgentsClient) NewListByVMPager(resourceGroupName string, virt if err != nil { return GuestAgentsClientListByVMResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GuestAgentsClientListByVMResponse{}, err } @@ -310,7 +305,7 @@ func (client *GuestAgentsClient) listByVMCreateRequest(ctx context.Context, reso return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go index 5aa7a93050d8..f00920289a12 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateGuestAgent.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateGuestAgent.json func ExampleGuestAgentsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewGuestAgentsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "ContosoVm", "default", armconnectedvmware.GuestAgent{ + poller, err := clientFactory.NewGuestAgentsClient().BeginCreate(ctx, "testrg", "ContosoVm", "default", armconnectedvmware.GuestAgent{ Properties: &armconnectedvmware.GuestAgentProperties{ Credentials: &armconnectedvmware.GuestCredential{ Password: to.Ptr(""), @@ -47,41 +56,63 @@ func ExampleGuestAgentsClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.GuestAgent = armconnectedvmware.GuestAgent{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/guestAgents"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/guestAgents/default"), + // Properties: &armconnectedvmware.GuestAgentProperties{ + // ProvisioningAction: to.Ptr(armconnectedvmware.ProvisioningActionInstall), + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr("connected"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetGuestAgent.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetGuestAgent.json func ExampleGuestAgentsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewGuestAgentsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "ContosoVm", "default", nil) + res, err := clientFactory.NewGuestAgentsClient().Get(ctx, "testrg", "ContosoVm", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.GuestAgent = armconnectedvmware.GuestAgent{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/guestAgents"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/guestAgents/default"), + // Properties: &armconnectedvmware.GuestAgentProperties{ + // ProvisioningAction: to.Ptr(armconnectedvmware.ProvisioningActionInstall), + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr("connected"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteGuestAgent.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteGuestAgent.json func ExampleGuestAgentsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewGuestAgentsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "ContosoVm", "default", nil) + poller, err := clientFactory.NewGuestAgentsClient().BeginDelete(ctx, "testrg", "ContosoVm", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -91,26 +122,40 @@ func ExampleGuestAgentsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GuestAgent_ListByVm.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GuestAgent_ListByVm.json func ExampleGuestAgentsClient_NewListByVMPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewGuestAgentsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByVMPager("testrg", "ContosoVm", nil) + pager := clientFactory.NewGuestAgentsClient().NewListByVMPager("testrg", "ContosoVm", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.GuestAgentList = armconnectedvmware.GuestAgentList{ + // Value: []*armconnectedvmware.GuestAgent{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/guestAgents"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/guestAgents/default"), + // Properties: &armconnectedvmware.GuestAgentProperties{ + // ProvisioningAction: to.Ptr(armconnectedvmware.ProvisioningActionInstall), + // ProvisioningState: to.Ptr("Succeeded"), + // Status: to.Ptr("connected"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go index 5f91f0c9f594..919a384f65c4 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,65 +33,58 @@ import ( // HostsClient contains the methods for the Hosts group. // Don't use this type directly, use NewHostsClient() instead. type HostsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewHostsClient creates a new instance of HostsClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewHostsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HostsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".HostsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &HostsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update host. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// hostName - Name of the host. -// body - Request payload. -// options - HostsClientBeginCreateOptions contains the optional parameters for the HostsClient.BeginCreate method. +// - resourceGroupName - The Resource Group Name. +// - hostName - Name of the host. +// - body - Request payload. +// - options - HostsClientBeginCreateOptions contains the optional parameters for the HostsClient.BeginCreate method. func (client *HostsClient) BeginCreate(ctx context.Context, resourceGroupName string, hostName string, body Host, options *HostsClientBeginCreateOptions) (*runtime.Poller[HostsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, hostName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[HostsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[HostsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[HostsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[HostsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update host. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *HostsClient) create(ctx context.Context, resourceGroupName string, hostName string, body Host, options *HostsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, hostName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -118,7 +109,7 @@ func (client *HostsClient) createCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter hostName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{hostName}", url.PathEscape(hostName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -131,31 +122,33 @@ func (client *HostsClient) createCreateRequest(ctx context.Context, resourceGrou // BeginDelete - Implements host DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// hostName - Name of the host. -// options - HostsClientBeginDeleteOptions contains the optional parameters for the HostsClient.BeginDelete method. +// - resourceGroupName - The Resource Group Name. +// - hostName - Name of the host. +// - options - HostsClientBeginDeleteOptions contains the optional parameters for the HostsClient.BeginDelete method. func (client *HostsClient) BeginDelete(ctx context.Context, resourceGroupName string, hostName string, options *HostsClientBeginDeleteOptions) (*runtime.Poller[HostsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, hostName, options) if err != nil { return nil, err } - return runtime.NewPoller[HostsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[HostsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[HostsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[HostsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements host DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *HostsClient) deleteOperation(ctx context.Context, resourceGroupName string, hostName string, options *HostsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, hostName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +173,7 @@ func (client *HostsClient) deleteCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter hostName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{hostName}", url.PathEscape(hostName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -196,16 +189,17 @@ func (client *HostsClient) deleteCreateRequest(ctx context.Context, resourceGrou // Get - Implements host GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// hostName - Name of the host. -// options - HostsClientGetOptions contains the optional parameters for the HostsClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - hostName - Name of the host. +// - options - HostsClientGetOptions contains the optional parameters for the HostsClient.Get method. func (client *HostsClient) Get(ctx context.Context, resourceGroupName string, hostName string, options *HostsClientGetOptions) (HostsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, hostName, options) if err != nil { return HostsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HostsClientGetResponse{}, err } @@ -230,7 +224,7 @@ func (client *HostsClient) getCreateRequest(ctx context.Context, resourceGroupNa return nil, errors.New("parameter hostName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{hostName}", url.PathEscape(hostName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -251,9 +245,9 @@ func (client *HostsClient) getHandleResponse(resp *http.Response) (HostsClientGe } // NewListPager - List of hosts in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - HostsClientListOptions contains the optional parameters for the HostsClient.List method. +// - options - HostsClientListOptions contains the optional parameters for the HostsClient.NewListPager method. func (client *HostsClient) NewListPager(options *HostsClientListOptions) *runtime.Pager[HostsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[HostsClientListResponse]{ More: func(page HostsClientListResponse) bool { @@ -270,7 +264,7 @@ func (client *HostsClient) NewListPager(options *HostsClientListOptions) *runtim if err != nil { return HostsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HostsClientListResponse{}, err } @@ -289,7 +283,7 @@ func (client *HostsClient) listCreateRequest(ctx context.Context, options *Hosts return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -310,11 +304,11 @@ func (client *HostsClient) listHandleResponse(resp *http.Response) (HostsClientL } // NewListByResourceGroupPager - List of hosts in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - HostsClientListByResourceGroupOptions contains the optional parameters for the HostsClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - HostsClientListByResourceGroupOptions contains the optional parameters for the HostsClient.NewListByResourceGroupPager +// method. func (client *HostsClient) NewListByResourceGroupPager(resourceGroupName string, options *HostsClientListByResourceGroupOptions) *runtime.Pager[HostsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[HostsClientListByResourceGroupResponse]{ More: func(page HostsClientListByResourceGroupResponse) bool { @@ -331,7 +325,7 @@ func (client *HostsClient) NewListByResourceGroupPager(resourceGroupName string, if err != nil { return HostsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HostsClientListByResourceGroupResponse{}, err } @@ -354,7 +348,7 @@ func (client *HostsClient) listByResourceGroupCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -376,17 +370,18 @@ func (client *HostsClient) listByResourceGroupHandleResponse(resp *http.Response // Update - API to update certain properties of the host resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// hostName - Name of the host. -// body - Resource properties to update. -// options - HostsClientUpdateOptions contains the optional parameters for the HostsClient.Update method. +// - resourceGroupName - The Resource Group Name. +// - hostName - Name of the host. +// - body - Resource properties to update. +// - options - HostsClientUpdateOptions contains the optional parameters for the HostsClient.Update method. func (client *HostsClient) Update(ctx context.Context, resourceGroupName string, hostName string, body ResourcePatch, options *HostsClientUpdateOptions) (HostsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, hostName, body, options) if err != nil { return HostsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HostsClientUpdateResponse{}, err } @@ -411,7 +406,7 @@ func (client *HostsClient) updateCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter hostName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{hostName}", url.PathEscape(hostName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go index 0414b88490bc..c802a27f39e6 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateHost.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateHost.json func ExampleHostsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHostsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "HRHost", armconnectedvmware.Host{ + poller, err := clientFactory.NewHostsClient().BeginCreate(ctx, "testrg", "HRHost", armconnectedvmware.Host{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -46,41 +55,73 @@ func ExampleHostsClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Host = armconnectedvmware.Host{ + // Name: to.Ptr("HRHost"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.HostProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetHost.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetHost.json func ExampleHostsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHostsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "HRHost", nil) + res, err := clientFactory.NewHostsClient().Get(ctx, "testrg", "HRHost", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Host = armconnectedvmware.Host{ + // Name: to.Ptr("HRHost"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.HostProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateHost.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateHost.json func ExampleHostsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHostsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "testrg", "HRHost", armconnectedvmware.ResourcePatch{ + res, err := clientFactory.NewHostsClient().Update(ctx, "testrg", "HRHost", armconnectedvmware.ResourcePatch{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -89,22 +130,42 @@ func ExampleHostsClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Host = armconnectedvmware.Host{ + // Name: to.Ptr("HRHost"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.HostProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteHost.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteHost.json func ExampleHostsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHostsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "HRHost", &armconnectedvmware.HostsClientBeginDeleteOptions{Force: nil}) + poller, err := clientFactory.NewHostsClient().BeginDelete(ctx, "testrg", "HRHost", &armconnectedvmware.HostsClientBeginDeleteOptions{Force: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -114,50 +175,88 @@ func ExampleHostsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListHosts.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListHosts.json func ExampleHostsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHostsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewHostsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.HostsList = armconnectedvmware.HostsList{ + // Value: []*armconnectedvmware.Host{ + // { + // Name: to.Ptr("HRHost"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.HostProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListHostsByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListHostsByResourceGroup.json func ExampleHostsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHostsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewHostsClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.HostsList = armconnectedvmware.HostsList{ + // Value: []*armconnectedvmware.Host{ + // { + // Name: to.Ptr("HRHost"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.HostProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go index f8d5d986f5a6..5b1aaf0dc2d2 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,50 +32,42 @@ import ( // HybridIdentityMetadataClient contains the methods for the HybridIdentityMetadata group. // Don't use this type directly, use NewHybridIdentityMetadataClient() instead. type HybridIdentityMetadataClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewHybridIdentityMetadataClient creates a new instance of HybridIdentityMetadataClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewHybridIdentityMetadataClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HybridIdentityMetadataClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".HybridIdentityMetadataClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &HybridIdentityMetadataClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create Or Update HybridIdentityMetadata. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// metadataName - Name of the hybridIdentityMetadata. -// body - Request payload. -// options - HybridIdentityMetadataClientCreateOptions contains the optional parameters for the HybridIdentityMetadataClient.Create -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - metadataName - Name of the hybridIdentityMetadata. +// - body - Request payload. +// - options - HybridIdentityMetadataClientCreateOptions contains the optional parameters for the HybridIdentityMetadataClient.Create +// method. func (client *HybridIdentityMetadataClient) Create(ctx context.Context, resourceGroupName string, virtualMachineName string, metadataName string, body HybridIdentityMetadata, options *HybridIdentityMetadataClientCreateOptions) (HybridIdentityMetadataClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineName, metadataName, body, options) if err != nil { return HybridIdentityMetadataClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HybridIdentityMetadataClientCreateResponse{}, err } @@ -106,7 +96,7 @@ func (client *HybridIdentityMetadataClient) createCreateRequest(ctx context.Cont return nil, errors.New("parameter metadataName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{metadataName}", url.PathEscape(metadataName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,18 +118,19 @@ func (client *HybridIdentityMetadataClient) createHandleResponse(resp *http.Resp // Delete - Implements HybridIdentityMetadata DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// metadataName - Name of the HybridIdentityMetadata. -// options - HybridIdentityMetadataClientDeleteOptions contains the optional parameters for the HybridIdentityMetadataClient.Delete -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - metadataName - Name of the HybridIdentityMetadata. +// - options - HybridIdentityMetadataClientDeleteOptions contains the optional parameters for the HybridIdentityMetadataClient.Delete +// method. func (client *HybridIdentityMetadataClient) Delete(ctx context.Context, resourceGroupName string, virtualMachineName string, metadataName string, options *HybridIdentityMetadataClientDeleteOptions) (HybridIdentityMetadataClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, metadataName, options) if err != nil { return HybridIdentityMetadataClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HybridIdentityMetadataClientDeleteResponse{}, err } @@ -168,7 +159,7 @@ func (client *HybridIdentityMetadataClient) deleteCreateRequest(ctx context.Cont return nil, errors.New("parameter metadataName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{metadataName}", url.PathEscape(metadataName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -181,18 +172,19 @@ func (client *HybridIdentityMetadataClient) deleteCreateRequest(ctx context.Cont // Get - Implements HybridIdentityMetadata GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// metadataName - Name of the HybridIdentityMetadata. -// options - HybridIdentityMetadataClientGetOptions contains the optional parameters for the HybridIdentityMetadataClient.Get -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - metadataName - Name of the HybridIdentityMetadata. +// - options - HybridIdentityMetadataClientGetOptions contains the optional parameters for the HybridIdentityMetadataClient.Get +// method. func (client *HybridIdentityMetadataClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, metadataName string, options *HybridIdentityMetadataClientGetOptions) (HybridIdentityMetadataClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, metadataName, options) if err != nil { return HybridIdentityMetadataClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HybridIdentityMetadataClientGetResponse{}, err } @@ -221,7 +213,7 @@ func (client *HybridIdentityMetadataClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter metadataName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{metadataName}", url.PathEscape(metadataName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -242,12 +234,12 @@ func (client *HybridIdentityMetadataClient) getHandleResponse(resp *http.Respons } // NewListByVMPager - Returns the list of HybridIdentityMetadata of the given vm. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the vm. -// options - HybridIdentityMetadataClientListByVMOptions contains the optional parameters for the HybridIdentityMetadataClient.ListByVM -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the vm. +// - options - HybridIdentityMetadataClientListByVMOptions contains the optional parameters for the HybridIdentityMetadataClient.NewListByVMPager +// method. func (client *HybridIdentityMetadataClient) NewListByVMPager(resourceGroupName string, virtualMachineName string, options *HybridIdentityMetadataClientListByVMOptions) *runtime.Pager[HybridIdentityMetadataClientListByVMResponse] { return runtime.NewPager(runtime.PagingHandler[HybridIdentityMetadataClientListByVMResponse]{ More: func(page HybridIdentityMetadataClientListByVMResponse) bool { @@ -264,7 +256,7 @@ func (client *HybridIdentityMetadataClient) NewListByVMPager(resourceGroupName s if err != nil { return HybridIdentityMetadataClientListByVMResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HybridIdentityMetadataClientListByVMResponse{}, err } @@ -291,7 +283,7 @@ func (client *HybridIdentityMetadataClient) listByVMCreateRequest(ctx context.Co return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go index 91659c822099..5a197feda9df 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateHybridIdentityMetadata.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateHybridIdentityMetadata.json func ExampleHybridIdentityMetadataClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "testrg", "ContosoVm", "default", armconnectedvmware.HybridIdentityMetadata{ + res, err := clientFactory.NewHybridIdentityMetadataClient().Create(ctx, "testrg", "ContosoVm", "default", armconnectedvmware.HybridIdentityMetadata{ Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), @@ -37,66 +46,114 @@ func ExampleHybridIdentityMetadataClient_Create() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.HybridIdentityMetadata = armconnectedvmware.HybridIdentityMetadata{ + // Name: to.Ptr("testItem"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/hybridIdentityMetadatas"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/hybridIdentityMetadatas/default"), + // Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ + // Identity: &armconnectedvmware.Identity{ + // Type: to.Ptr(armconnectedvmware.IdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("7b5129bc-8642-4a6a-95f8-63400ca6ec4d"), + // TenantID: to.Ptr("ec46ca82-5d4a-4e3e-b4b7-e27f9318645d"), + // }, + // PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), + // VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetHybridIdentityMetadata.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetHybridIdentityMetadata.json func ExampleHybridIdentityMetadataClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "ContosoVm", "default", nil) + res, err := clientFactory.NewHybridIdentityMetadataClient().Get(ctx, "testrg", "ContosoVm", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.HybridIdentityMetadata = armconnectedvmware.HybridIdentityMetadata{ + // Name: to.Ptr("testItem"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/hybridIdentityMetadatas"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/hybridIdentityMetadatas/default"), + // Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ + // Identity: &armconnectedvmware.Identity{ + // Type: to.Ptr(armconnectedvmware.IdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("7b5129bc-8642-4a6a-95f8-63400ca6ec4d"), + // TenantID: to.Ptr("ec46ca82-5d4a-4e3e-b4b7-e27f9318645d"), + // }, + // PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), + // VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteHybridIdentityMetadata.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteHybridIdentityMetadata.json func ExampleHybridIdentityMetadataClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "testrg", "ContosoVm", "default", nil) + _, err = clientFactory.NewHybridIdentityMetadataClient().Delete(ctx, "testrg", "ContosoVm", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/HybridIdentityMetadata_ListByVm.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/HybridIdentityMetadata_ListByVm.json func ExampleHybridIdentityMetadataClient_NewListByVMPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByVMPager("testrg", "ContosoVm", nil) + pager := clientFactory.NewHybridIdentityMetadataClient().NewListByVMPager("testrg", "ContosoVm", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.HybridIdentityMetadataList = armconnectedvmware.HybridIdentityMetadataList{ + // Value: []*armconnectedvmware.HybridIdentityMetadata{ + // { + // Name: to.Ptr("testItem"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/hybridIdentityMetadatas"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/hybridIdentityMetadatas/default"), + // Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ + // Identity: &armconnectedvmware.Identity{ + // Type: to.Ptr(armconnectedvmware.IdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("7b5129bc-8642-4a6a-95f8-63400ca6ec4d"), + // TenantID: to.Ptr("ec46ca82-5d4a-4e3e-b4b7-e27f9318645d"), + // }, + // PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), + // VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go index 5402eb24c436..3de03e5139f2 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,49 +32,41 @@ import ( // InventoryItemsClient contains the methods for the InventoryItems group. // Don't use this type directly, use NewInventoryItemsClient() instead. type InventoryItemsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewInventoryItemsClient creates a new instance of InventoryItemsClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewInventoryItemsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InventoryItemsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".InventoryItemsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &InventoryItemsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create Or Update InventoryItem. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// inventoryItemName - Name of the inventoryItem. -// body - Request payload. -// options - InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - inventoryItemName - Name of the inventoryItem. +// - body - Request payload. +// - options - InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. func (client *InventoryItemsClient) Create(ctx context.Context, resourceGroupName string, vcenterName string, inventoryItemName string, body InventoryItem, options *InventoryItemsClientCreateOptions) (InventoryItemsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, vcenterName, inventoryItemName, body, options) if err != nil { return InventoryItemsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InventoryItemsClientCreateResponse{}, err } @@ -105,7 +95,7 @@ func (client *InventoryItemsClient) createCreateRequest(ctx context.Context, res return nil, errors.New("parameter inventoryItemName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -127,17 +117,18 @@ func (client *InventoryItemsClient) createHandleResponse(resp *http.Response) (I // Delete - Implements inventoryItem DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// inventoryItemName - Name of the inventoryItem. -// options - InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - inventoryItemName - Name of the inventoryItem. +// - options - InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. func (client *InventoryItemsClient) Delete(ctx context.Context, resourceGroupName string, vcenterName string, inventoryItemName string, options *InventoryItemsClientDeleteOptions) (InventoryItemsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, vcenterName, inventoryItemName, options) if err != nil { return InventoryItemsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InventoryItemsClientDeleteResponse{}, err } @@ -166,7 +157,7 @@ func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter inventoryItemName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -179,17 +170,18 @@ func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, res // Get - Implements InventoryItem GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// inventoryItemName - Name of the inventoryItem. -// options - InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - inventoryItemName - Name of the inventoryItem. +// - options - InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. func (client *InventoryItemsClient) Get(ctx context.Context, resourceGroupName string, vcenterName string, inventoryItemName string, options *InventoryItemsClientGetOptions) (InventoryItemsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, vcenterName, inventoryItemName, options) if err != nil { return InventoryItemsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InventoryItemsClientGetResponse{}, err } @@ -218,7 +210,7 @@ func (client *InventoryItemsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter inventoryItemName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -239,12 +231,12 @@ func (client *InventoryItemsClient) getHandleResponse(resp *http.Response) (Inve } // NewListByVCenterPager - Returns the list of inventoryItems of the given vCenter. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// options - InventoryItemsClientListByVCenterOptions contains the optional parameters for the InventoryItemsClient.ListByVCenter -// method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - options - InventoryItemsClientListByVCenterOptions contains the optional parameters for the InventoryItemsClient.NewListByVCenterPager +// method. func (client *InventoryItemsClient) NewListByVCenterPager(resourceGroupName string, vcenterName string, options *InventoryItemsClientListByVCenterOptions) *runtime.Pager[InventoryItemsClientListByVCenterResponse] { return runtime.NewPager(runtime.PagingHandler[InventoryItemsClientListByVCenterResponse]{ More: func(page InventoryItemsClientListByVCenterResponse) bool { @@ -261,7 +253,7 @@ func (client *InventoryItemsClient) NewListByVCenterPager(resourceGroupName stri if err != nil { return InventoryItemsClientListByVCenterResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return InventoryItemsClientListByVCenterResponse{}, err } @@ -288,7 +280,7 @@ func (client *InventoryItemsClient) listByVCenterCreateRequest(ctx context.Conte return nil, errors.New("parameter vcenterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vcenterName}", url.PathEscape(vcenterName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go index d9641d6bac31..6048d98a262d 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateInventoryItem.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateInventoryItem.json func ExampleInventoryItemsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewInventoryItemsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "testrg", "ContosoVCenter", "testItem", armconnectedvmware.InventoryItem{ + res, err := clientFactory.NewInventoryItemsClient().Create(ctx, "testrg", "ContosoVCenter", "testItem", armconnectedvmware.InventoryItem{ Properties: &armconnectedvmware.ResourcePoolInventoryItem{ InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), }, @@ -36,66 +45,96 @@ func ExampleInventoryItemsClient_Create() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.InventoryItem = armconnectedvmware.InventoryItem{ + // Name: to.Ptr("testItem"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters/InventoryItems"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter/InventoryItems/testItem"), + // Properties: &armconnectedvmware.ResourcePoolInventoryItem{ + // InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetInventoryItem.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetInventoryItem.json func ExampleInventoryItemsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewInventoryItemsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "ContosoVCenter", "testItem", nil) + res, err := clientFactory.NewInventoryItemsClient().Get(ctx, "testrg", "ContosoVCenter", "testItem", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.InventoryItem = armconnectedvmware.InventoryItem{ + // Name: to.Ptr("testItem"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters/InventoryItems"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter/InventoryItems/testItem"), + // Properties: &armconnectedvmware.ResourcePoolInventoryItem{ + // InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteInventoryItem.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteInventoryItem.json func ExampleInventoryItemsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewInventoryItemsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "testrg", "ContosoVCenter", "testItem", nil) + _, err = clientFactory.NewInventoryItemsClient().Delete(ctx, "testrg", "ContosoVCenter", "testItem", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/InventoryItems_ListByVCenter.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/InventoryItems_ListByVCenter.json func ExampleInventoryItemsClient_NewListByVCenterPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewInventoryItemsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByVCenterPager("testrg", "ContosoVCenter", nil) + pager := clientFactory.NewInventoryItemsClient().NewListByVCenterPager("testrg", "ContosoVCenter", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.InventoryItemsList = armconnectedvmware.InventoryItemsList{ + // Value: []*armconnectedvmware.InventoryItem{ + // { + // Name: to.Ptr("testItem"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters/InventoryItems"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter/InventoryItems/testItem"), + // Properties: &armconnectedvmware.ResourcePoolInventoryItem{ + // InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go index 6da8e511624a..649c728d2115 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,67 +32,60 @@ import ( // MachineExtensionsClient contains the methods for the MachineExtensions group. // Don't use this type directly, use NewMachineExtensionsClient() instead. type MachineExtensionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMachineExtensionsClient creates a new instance of MachineExtensionsClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMachineExtensionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MachineExtensionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MachineExtensionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MachineExtensionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - The operation to create or update the extension. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// name - The name of the machine where the extension should be created or updated. -// extensionName - The name of the machine extension. -// extensionParameters - Parameters supplied to the Create Machine Extension operation. -// options - MachineExtensionsClientBeginCreateOrUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The Resource Group Name. +// - name - The name of the machine where the extension should be created or updated. +// - extensionName - The name of the machine extension. +// - extensionParameters - Parameters supplied to the Create Machine Extension operation. +// - options - MachineExtensionsClientBeginCreateOrUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginCreateOrUpdate +// method. func (client *MachineExtensionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[MachineExtensionsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, name, extensionName, extensionParameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MachineExtensionsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MachineExtensionsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[MachineExtensionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MachineExtensionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - The operation to create or update the extension. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *MachineExtensionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, name, extensionName, extensionParameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -123,7 +114,7 @@ func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter extensionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -136,33 +127,35 @@ func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.C // BeginDelete - The operation to delete the extension. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// name - The name of the machine where the extension should be deleted. -// extensionName - The name of the machine extension. -// options - MachineExtensionsClientBeginDeleteOptions contains the optional parameters for the MachineExtensionsClient.BeginDelete -// method. +// - resourceGroupName - The Resource Group Name. +// - name - The name of the machine where the extension should be deleted. +// - extensionName - The name of the machine extension. +// - options - MachineExtensionsClientBeginDeleteOptions contains the optional parameters for the MachineExtensionsClient.BeginDelete +// method. func (client *MachineExtensionsClient) BeginDelete(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*runtime.Poller[MachineExtensionsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, name, extensionName, options) if err != nil { return nil, err } - return runtime.NewPoller[MachineExtensionsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[MachineExtensionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[MachineExtensionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MachineExtensionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - The operation to delete the extension. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *MachineExtensionsClient) deleteOperation(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, name, extensionName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -191,7 +184,7 @@ func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter extensionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -204,17 +197,18 @@ func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, // Get - The operation to get the extension. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// name - The name of the machine containing the extension. -// extensionName - The name of the machine extension. -// options - MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - name - The name of the machine containing the extension. +// - extensionName - The name of the machine extension. +// - options - MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. func (client *MachineExtensionsClient) Get(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientGetOptions) (MachineExtensionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, name, extensionName, options) if err != nil { return MachineExtensionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MachineExtensionsClientGetResponse{}, err } @@ -243,7 +237,7 @@ func (client *MachineExtensionsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter extensionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -264,11 +258,12 @@ func (client *MachineExtensionsClient) getHandleResponse(resp *http.Response) (M } // NewListPager - The operation to get all extensions of a non-Azure machine -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// name - The name of the machine containing the extension. -// options - MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.List method. +// - resourceGroupName - The Resource Group Name. +// - name - The name of the machine containing the extension. +// - options - MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.NewListPager +// method. func (client *MachineExtensionsClient) NewListPager(resourceGroupName string, name string, options *MachineExtensionsClientListOptions) *runtime.Pager[MachineExtensionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MachineExtensionsClientListResponse]{ More: func(page MachineExtensionsClientListResponse) bool { @@ -285,7 +280,7 @@ func (client *MachineExtensionsClient) NewListPager(resourceGroupName string, na if err != nil { return MachineExtensionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MachineExtensionsClientListResponse{}, err } @@ -312,7 +307,7 @@ func (client *MachineExtensionsClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -337,34 +332,36 @@ func (client *MachineExtensionsClient) listHandleResponse(resp *http.Response) ( // BeginUpdate - The operation to update the extension. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// name - The name of the machine where the extension should be created or updated. -// extensionName - The name of the machine extension. -// extensionParameters - Parameters supplied to the Create Machine Extension operation. -// options - MachineExtensionsClientBeginUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginUpdate -// method. +// - resourceGroupName - The Resource Group Name. +// - name - The name of the machine where the extension should be created or updated. +// - extensionName - The name of the machine extension. +// - extensionParameters - Parameters supplied to the Create Machine Extension operation. +// - options - MachineExtensionsClientBeginUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginUpdate +// method. func (client *MachineExtensionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*runtime.Poller[MachineExtensionsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, name, extensionName, extensionParameters, options) if err != nil { return nil, err } - return runtime.NewPoller[MachineExtensionsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[MachineExtensionsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[MachineExtensionsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MachineExtensionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - The operation to update the extension. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *MachineExtensionsClient) update(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, name, extensionName, extensionParameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -393,7 +390,7 @@ func (client *MachineExtensionsClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter extensionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go index f5062e35f755..2acadff22602 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,23 +26,23 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/PUTExtension.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/PUTExtension.json func ExampleMachineExtensionsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewMachineExtensionsClient("{subscriptionId}", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", armconnectedvmware.MachineExtension{ + poller, err := clientFactory.NewMachineExtensionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", armconnectedvmware.MachineExtension{ Location: to.Ptr("eastus2euap"), Properties: &armconnectedvmware.MachineExtensionProperties{ Type: to.Ptr("CustomScriptExtension"), Publisher: to.Ptr("Microsoft.Compute"), - Settings: map[string]interface{}{ + Settings: map[string]any{ "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"", }, TypeHandlerVersion: to.Ptr("1.10"), @@ -46,26 +55,52 @@ func ExampleMachineExtensionsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MachineExtension = armconnectedvmware.MachineExtension{ + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), + // Location: to.Ptr("eastus2euap"), + // Properties: &armconnectedvmware.MachineExtensionProperties{ + // Type: to.Ptr("string"), + // AutoUpgradeMinorVersion: to.Ptr(false), + // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("CustomScriptExtension"), + // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ + // Code: to.Ptr("success"), + // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), + // Message: to.Ptr("Finished executing command, StdOut: , StdErr:"), + // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-08T20:42:10.999Z"); return t}()), + // }, + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Publisher: to.Ptr("Microsoft.Compute"), + // Settings: "@{commandToExecute=powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"}", + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateExtension.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateExtension.json func ExampleMachineExtensionsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewMachineExtensionsClient("{subscriptionId}", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", armconnectedvmware.MachineExtensionUpdate{ + poller, err := clientFactory.NewMachineExtensionsClient().BeginUpdate(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", armconnectedvmware.MachineExtensionUpdate{ Properties: &armconnectedvmware.MachineExtensionUpdateProperties{ Type: to.Ptr("CustomScriptExtension"), Publisher: to.Ptr("Microsoft.Compute"), - Settings: map[string]interface{}{ + Settings: map[string]any{ "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -lt 100 }\"", }, TypeHandlerVersion: to.Ptr("1.10"), @@ -78,22 +113,48 @@ func ExampleMachineExtensionsClient_BeginUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MachineExtension = armconnectedvmware.MachineExtension{ + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), + // Location: to.Ptr("eastus2euap"), + // Properties: &armconnectedvmware.MachineExtensionProperties{ + // Type: to.Ptr("string"), + // AutoUpgradeMinorVersion: to.Ptr(false), + // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("CustomScriptExtension"), + // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ + // Code: to.Ptr("success"), + // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), + // Message: to.Ptr("Finished executing command, StdOut: , StdErr:"), + // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-08T20:42:10.999Z"); return t}()), + // }, + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Publisher: to.Ptr("Microsoft.Compute"), + // Settings: "@{commandToExecute=powershell.exe -c \"Get-Process | Where-Object { $_.CPU -lt 100 }\"}", + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DELETEExtension.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DELETEExtension.json func ExampleMachineExtensionsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewMachineExtensionsClient("{subscriptionId}", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myMachine", "MMA", nil) + poller, err := clientFactory.NewMachineExtensionsClient().BeginDelete(ctx, "myResourceGroup", "myMachine", "MMA", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -103,45 +164,126 @@ func ExampleMachineExtensionsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GETExtension.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GETExtension.json func ExampleMachineExtensionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewMachineExtensionsClient("{subscriptionId}", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", nil) + res, err := clientFactory.NewMachineExtensionsClient().Get(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MachineExtension = armconnectedvmware.MachineExtension{ + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), + // Location: to.Ptr("eastus2euap"), + // Properties: &armconnectedvmware.MachineExtensionProperties{ + // Type: to.Ptr("string"), + // AutoUpgradeMinorVersion: to.Ptr(false), + // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("CustomScriptExtension"), + // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ + // Code: to.Ptr("success"), + // DisplayStatus: to.Ptr("Provisioning succeeded"), + // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), + // Message: to.Ptr("Finished executing command, StdOut: , StdErr:"), + // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-08T20:42:10.999Z"); return t}()), + // }, + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Publisher: to.Ptr("Microsoft.Compute"), + // Settings: "@{commandToExecute=powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"}", + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/LISTExtension.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/LISTExtension.json func ExampleMachineExtensionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewMachineExtensionsClient("{subscriptionId}", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMachine", &armconnectedvmware.MachineExtensionsClientListOptions{Expand: nil}) + pager := clientFactory.NewMachineExtensionsClient().NewListPager("myResourceGroup", "myMachine", &armconnectedvmware.MachineExtensionsClientListOptions{Expand: nil}) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.MachineExtensionsListResult = armconnectedvmware.MachineExtensionsListResult{ + // Value: []*armconnectedvmware.MachineExtension{ + // { + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), + // Location: to.Ptr("eastus2euap"), + // Properties: &armconnectedvmware.MachineExtensionProperties{ + // Type: to.Ptr("CustomScriptExtension"), + // AutoUpgradeMinorVersion: to.Ptr(false), + // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ + // Name: to.Ptr("CustomScriptExtension"), + // Type: to.Ptr("CustomScriptExtension"), + // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ + // Code: to.Ptr("success"), + // DisplayStatus: to.Ptr("Provisioning succeeded"), + // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), + // Message: to.Ptr("formattedMessage: Finished executing command, StdOut: , StdErr: "), + // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-13T17:18:57.405Z"); return t}()), + // }, + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Publisher: to.Ptr("Microsoft.Compute"), + // Settings: map[string]any{ + // "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"", + // }, + // TypeHandlerVersion: to.Ptr("1.10.3"), + // }, + // }, + // { + // Name: to.Ptr("winosupdateextension"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), + // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/winosupdateextension"), + // Location: to.Ptr("eastus2euap"), + // Properties: &armconnectedvmware.MachineExtensionProperties{ + // Type: to.Ptr("windowsosupdateextension"), + // AutoUpgradeMinorVersion: to.Ptr(false), + // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ + // Name: to.Ptr("winosupdateextension"), + // Type: to.Ptr("windowsosupdateextension"), + // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ + // }, + // TypeHandlerVersion: to.Ptr("1.0.0.0"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // Publisher: to.Ptr("microsoft.softwareupdatemanagement.test"), + // Settings: map[string]any{ + // }, + // TypeHandlerVersion: to.Ptr("1.0.0.0"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go index 5b3c4d8bf206..696cf8814dcb 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go @@ -162,12 +162,13 @@ type ClustersClientGetOptions struct { // placeholder for future optional parameters } -// ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.ListByResourceGroup method. +// ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.NewListByResourceGroupPager +// method. type ClustersClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ClustersClientListOptions contains the optional parameters for the ClustersClient.List method. +// ClustersClientListOptions contains the optional parameters for the ClustersClient.NewListPager method. type ClustersClientListOptions struct { // placeholder for future optional parameters } @@ -186,21 +187,6 @@ type ClustersList struct { NextLink *string `json:"nextLink,omitempty"` } -// Condition defines an extension to status. -type Condition struct { - // READ-ONLY; A human readable message indicating details about the status. - Message *string `json:"message,omitempty" azure:"ro"` - - // READ-ONLY; The reason for the condition's status. - Reason *string `json:"reason,omitempty" azure:"ro"` - - // READ-ONLY; Severity with which to treat failures of this type of condition. - Severity *string `json:"severity,omitempty" azure:"ro"` - - // READ-ONLY; Status of the condition. - Status *string `json:"status,omitempty" azure:"ro"` -} - // Datastore - Define the datastore. type Datastore struct { // REQUIRED; Gets or sets the location. @@ -314,13 +300,13 @@ type DatastoresClientGetOptions struct { // placeholder for future optional parameters } -// DatastoresClientListByResourceGroupOptions contains the optional parameters for the DatastoresClient.ListByResourceGroup +// DatastoresClientListByResourceGroupOptions contains the optional parameters for the DatastoresClient.NewListByResourceGroupPager // method. type DatastoresClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// DatastoresClientListOptions contains the optional parameters for the DatastoresClient.List method. +// DatastoresClientListOptions contains the optional parameters for the DatastoresClient.NewListPager method. type DatastoresClientListOptions struct { // placeholder for future optional parameters } @@ -339,18 +325,6 @@ type DatastoresList struct { NextLink *string `json:"nextLink,omitempty"` } -// ErrorDefinition - Error definition. -type ErrorDefinition struct { - // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. - Code *string `json:"code,omitempty" azure:"ro"` - - // READ-ONLY; Internal error details. - Details []*ErrorDefinition `json:"details,omitempty" azure:"ro"` - - // READ-ONLY; Description of the error. - Message *string `json:"message,omitempty" azure:"ro"` -} - // ErrorDetail - Error details. type ErrorDetail struct { // REQUIRED; The error's code. @@ -366,12 +340,6 @@ type ErrorDetail struct { Target *string `json:"target,omitempty"` } -// ErrorResponse - Error response. -type ErrorResponse struct { - // The error details. - Error *ErrorDefinition `json:"error,omitempty"` -} - // ExtendedLocation - The extended location. type ExtendedLocation struct { // The extended location name. @@ -470,7 +438,7 @@ type GuestAgentsClientGetOptions struct { // placeholder for future optional parameters } -// GuestAgentsClientListByVMOptions contains the optional parameters for the GuestAgentsClient.ListByVM method. +// GuestAgentsClientListByVMOptions contains the optional parameters for the GuestAgentsClient.NewListByVMPager method. type GuestAgentsClientListByVMOptions struct { // placeholder for future optional parameters } @@ -621,12 +589,13 @@ type HostsClientGetOptions struct { // placeholder for future optional parameters } -// HostsClientListByResourceGroupOptions contains the optional parameters for the HostsClient.ListByResourceGroup method. +// HostsClientListByResourceGroupOptions contains the optional parameters for the HostsClient.NewListByResourceGroupPager +// method. type HostsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// HostsClientListOptions contains the optional parameters for the HostsClient.List method. +// HostsClientListOptions contains the optional parameters for the HostsClient.NewListPager method. type HostsClientListOptions struct { // placeholder for future optional parameters } @@ -680,7 +649,7 @@ type HybridIdentityMetadataClientGetOptions struct { // placeholder for future optional parameters } -// HybridIdentityMetadataClientListByVMOptions contains the optional parameters for the HybridIdentityMetadataClient.ListByVM +// HybridIdentityMetadataClientListByVMOptions contains the optional parameters for the HybridIdentityMetadataClient.NewListByVMPager // method. type HybridIdentityMetadataClientListByVMOptions struct { // placeholder for future optional parameters @@ -800,7 +769,8 @@ type InventoryItemsClientGetOptions struct { // placeholder for future optional parameters } -// InventoryItemsClientListByVCenterOptions contains the optional parameters for the InventoryItemsClient.ListByVCenter method. +// InventoryItemsClientListByVCenterOptions contains the optional parameters for the InventoryItemsClient.NewListByVCenterPager +// method. type InventoryItemsClientListByVCenterOptions struct { // placeholder for future optional parameters } @@ -850,21 +820,6 @@ type MachineExtension struct { Type *string `json:"type,omitempty" azure:"ro"` } -// MachineExtensionInstanceView - Describes the Machine Extension Instance View. -type MachineExtensionInstanceView struct { - // Instance view status. - Status *MachineExtensionInstanceViewStatus `json:"status,omitempty"` - - // READ-ONLY; The machine extension name. - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Specifies the type of the extension; an example is "CustomScriptExtension". - Type *string `json:"type,omitempty" azure:"ro"` - - // READ-ONLY; Specifies the version of the script handler. - TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty" azure:"ro"` -} - // MachineExtensionInstanceViewStatus - Instance view status. type MachineExtensionInstanceViewStatus struct { // READ-ONLY; The status code. @@ -900,13 +855,13 @@ type MachineExtensionProperties struct { InstanceView *MachineExtensionPropertiesInstanceView `json:"instanceView,omitempty"` // The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - ProtectedSettings interface{} `json:"protectedSettings,omitempty"` + ProtectedSettings any `json:"protectedSettings,omitempty"` // The name of the extension handler publisher. Publisher *string `json:"publisher,omitempty"` // Json formatted public settings for the extension. - Settings interface{} `json:"settings,omitempty"` + Settings any `json:"settings,omitempty"` // Specifies the type of the extension; an example is "CustomScriptExtension". Type *string `json:"type,omitempty"` @@ -956,13 +911,13 @@ type MachineExtensionUpdateProperties struct { ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` // The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - ProtectedSettings interface{} `json:"protectedSettings,omitempty"` + ProtectedSettings any `json:"protectedSettings,omitempty"` // The name of the extension handler publisher. Publisher *string `json:"publisher,omitempty"` // Json formatted public settings for the extension. - Settings interface{} `json:"settings,omitempty"` + Settings any `json:"settings,omitempty"` // Specifies the type of the extension; an example is "CustomScriptExtension". Type *string `json:"type,omitempty"` @@ -997,7 +952,7 @@ type MachineExtensionsClientGetOptions struct { // placeholder for future optional parameters } -// MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.List method. +// MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.NewListPager method. type MachineExtensionsClientListOptions struct { // The expand expression to apply on the operation. Expand *string @@ -1146,7 +1101,7 @@ type OperationDisplay struct { Resource *string `json:"resource,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -1256,31 +1211,6 @@ type PlacementProfile struct { ResourcePoolID *string `json:"resourcePoolId,omitempty"` } -// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a -// location -type ProxyResource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// Resource - Common fields that are returned in the response for all Azure Resource Manager resources -type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - // ResourcePatch - Object containing updates for patch operations. type ResourcePatch struct { // Resource tags. @@ -1419,13 +1349,13 @@ type ResourcePoolsClientGetOptions struct { // placeholder for future optional parameters } -// ResourcePoolsClientListByResourceGroupOptions contains the optional parameters for the ResourcePoolsClient.ListByResourceGroup +// ResourcePoolsClientListByResourceGroupOptions contains the optional parameters for the ResourcePoolsClient.NewListByResourceGroupPager // method. type ResourcePoolsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.List method. +// ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.NewListPager method. type ResourcePoolsClientListOptions struct { // placeholder for future optional parameters } @@ -1604,12 +1534,13 @@ type VCentersClientGetOptions struct { // placeholder for future optional parameters } -// VCentersClientListByResourceGroupOptions contains the optional parameters for the VCentersClient.ListByResourceGroup method. +// VCentersClientListByResourceGroupOptions contains the optional parameters for the VCentersClient.NewListByResourceGroupPager +// method. type VCentersClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// VCentersClientListOptions contains the optional parameters for the VCentersClient.List method. +// VCentersClientListOptions contains the optional parameters for the VCentersClient.NewListPager method. type VCentersClientListOptions struct { // placeholder for future optional parameters } @@ -2131,13 +2062,14 @@ type VirtualMachineTemplatesClientGetOptions struct { // placeholder for future optional parameters } -// VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.ListByResourceGroup +// VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListByResourceGroupPager // method. type VirtualMachineTemplatesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.List method. +// VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListPager +// method. type VirtualMachineTemplatesClientListOptions struct { // placeholder for future optional parameters } @@ -2245,13 +2177,13 @@ type VirtualMachinesClientGetOptions struct { // placeholder for future optional parameters } -// VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.ListByResourceGroup +// VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager // method. type VirtualMachinesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.List method. +// VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.NewListPager method. type VirtualMachinesClientListOptions struct { // placeholder for future optional parameters } @@ -2372,13 +2304,13 @@ type VirtualNetworksClientGetOptions struct { // placeholder for future optional parameters } -// VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.ListByResourceGroup +// VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.NewListByResourceGroupPager // method. type VirtualNetworksClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.List method. +// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager method. type VirtualNetworksClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go index d13c7fcca55d..ffce487887c7 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go @@ -26,7 +26,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type AvailablePatchCountByClassification. func (a AvailablePatchCountByClassification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "critical", a.Critical) populate(objectMap, "definition", a.Definition) populate(objectMap, "featurePack", a.FeaturePack) @@ -85,7 +85,7 @@ func (a *AvailablePatchCountByClassification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Cluster. func (c Cluster) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", c.ExtendedLocation) populate(objectMap, "id", c.ID) populate(objectMap, "kind", c.Kind) @@ -144,7 +144,7 @@ func (c *Cluster) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ClusterInventoryItem. func (c ClusterInventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["inventoryType"] = InventoryTypeCluster populate(objectMap, "managedResourceId", c.ManagedResourceID) populate(objectMap, "moName", c.MoName) @@ -187,7 +187,7 @@ func (c *ClusterInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ClusterProperties. func (c ClusterProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customResourceName", c.CustomResourceName) populate(objectMap, "datastoreIds", c.DatastoreIDs) populate(objectMap, "inventoryItemId", c.InventoryItemID) @@ -250,7 +250,7 @@ func (c *ClusterProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ClustersList. func (c ClustersList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -279,48 +279,9 @@ func (c *ClustersList) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Condition. -func (c Condition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "message", c.Message) - populate(objectMap, "reason", c.Reason) - populate(objectMap, "severity", c.Severity) - populate(objectMap, "status", c.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Condition. -func (c *Condition) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "message": - err = unpopulate(val, "Message", &c.Message) - delete(rawMsg, key) - case "reason": - err = unpopulate(val, "Reason", &c.Reason) - delete(rawMsg, key) - case "severity": - err = unpopulate(val, "Severity", &c.Severity) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &c.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type Datastore. func (d Datastore) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", d.ExtendedLocation) populate(objectMap, "id", d.ID) populate(objectMap, "kind", d.Kind) @@ -379,7 +340,7 @@ func (d *Datastore) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DatastoreInventoryItem. func (d DatastoreInventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "capacityGB", d.CapacityGB) populate(objectMap, "freeSpaceGB", d.FreeSpaceGB) objectMap["inventoryType"] = InventoryTypeDatastore @@ -430,7 +391,7 @@ func (d *DatastoreInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DatastoreProperties. func (d DatastoreProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customResourceName", d.CustomResourceName) populate(objectMap, "inventoryItemId", d.InventoryItemID) populate(objectMap, "moName", d.MoName) @@ -485,7 +446,7 @@ func (d *DatastoreProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DatastoresList. func (d DatastoresList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -514,44 +475,9 @@ func (d *DatastoresList) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. -func (e ErrorDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDefinition. -func (e *ErrorDefinition) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) populate(objectMap, "message", e.Message) @@ -588,36 +514,9 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. -func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "error", e.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (e *ErrorResponse) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ExtendedLocation. func (e ExtendedLocation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", e.Name) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -648,7 +547,7 @@ func (e *ExtendedLocation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GuestAgent. func (g GuestAgent) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) @@ -691,7 +590,7 @@ func (g *GuestAgent) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GuestAgentList. func (g GuestAgentList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", g.NextLink) populate(objectMap, "value", g.Value) return json.Marshal(objectMap) @@ -722,7 +621,7 @@ func (g *GuestAgentList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GuestAgentProfile. func (g GuestAgentProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "agentVersion", g.AgentVersion) populate(objectMap, "errorDetails", g.ErrorDetails) populateTimeRFC3339(objectMap, "lastStatusChange", g.LastStatusChange) @@ -765,7 +664,7 @@ func (g *GuestAgentProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GuestAgentProperties. func (g GuestAgentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "credentials", g.Credentials) populate(objectMap, "customResourceName", g.CustomResourceName) populate(objectMap, "httpProxyConfig", g.HTTPProxyConfig) @@ -820,7 +719,7 @@ func (g *GuestAgentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GuestCredential. func (g GuestCredential) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "password", g.Password) populate(objectMap, "username", g.Username) return json.Marshal(objectMap) @@ -851,7 +750,7 @@ func (g *GuestCredential) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HTTPProxyConfiguration. func (h HTTPProxyConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "httpsProxy", h.HTTPSProxy) return json.Marshal(objectMap) } @@ -878,7 +777,7 @@ func (h *HTTPProxyConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HardwareProfile. func (h HardwareProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cpuHotAddEnabled", h.CPUHotAddEnabled) populate(objectMap, "cpuHotRemoveEnabled", h.CPUHotRemoveEnabled) populate(objectMap, "memoryHotAddEnabled", h.MemoryHotAddEnabled) @@ -925,7 +824,7 @@ func (h *HardwareProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Host. func (h Host) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", h.ExtendedLocation) populate(objectMap, "id", h.ID) populate(objectMap, "kind", h.Kind) @@ -984,7 +883,7 @@ func (h *Host) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HostInventoryItem. func (h HostInventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["inventoryType"] = InventoryTypeHost populate(objectMap, "managedResourceId", h.ManagedResourceID) populate(objectMap, "moName", h.MoName) @@ -1031,7 +930,7 @@ func (h *HostInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HostProperties. func (h HostProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customResourceName", h.CustomResourceName) populate(objectMap, "inventoryItemId", h.InventoryItemID) populate(objectMap, "moName", h.MoName) @@ -1086,7 +985,7 @@ func (h *HostProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HostsList. func (h HostsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", h.NextLink) populate(objectMap, "value", h.Value) return json.Marshal(objectMap) @@ -1117,7 +1016,7 @@ func (h *HostsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HybridIdentityMetadata. func (h HybridIdentityMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", h.ID) populate(objectMap, "name", h.Name) populate(objectMap, "properties", h.Properties) @@ -1160,7 +1059,7 @@ func (h *HybridIdentityMetadata) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HybridIdentityMetadataList. func (h HybridIdentityMetadataList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", h.NextLink) populate(objectMap, "value", h.Value) return json.Marshal(objectMap) @@ -1191,7 +1090,7 @@ func (h *HybridIdentityMetadataList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HybridIdentityMetadataProperties. func (h HybridIdentityMetadataProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", h.Identity) populate(objectMap, "provisioningState", h.ProvisioningState) populate(objectMap, "publicKey", h.PublicKey) @@ -1230,7 +1129,7 @@ func (h *HybridIdentityMetadataProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Identity. func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalId", i.PrincipalID) populate(objectMap, "tenantId", i.TenantID) populate(objectMap, "type", i.Type) @@ -1265,7 +1164,7 @@ func (i *Identity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InventoryItem. func (i InventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "kind", i.Kind) populate(objectMap, "name", i.Name) @@ -1312,7 +1211,7 @@ func (i *InventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InventoryItemDetails. func (i InventoryItemDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inventoryItemId", i.InventoryItemID) populate(objectMap, "moName", i.MoName) return json.Marshal(objectMap) @@ -1343,7 +1242,7 @@ func (i *InventoryItemDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InventoryItemProperties. func (i InventoryItemProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["inventoryType"] = i.InventoryType populate(objectMap, "managedResourceId", i.ManagedResourceID) populate(objectMap, "moName", i.MoName) @@ -1386,7 +1285,7 @@ func (i *InventoryItemProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InventoryItemsList. func (i InventoryItemsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", i.NextLink) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) @@ -1417,7 +1316,7 @@ func (i *InventoryItemsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LinuxParameters. func (l LinuxParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "classificationsToInclude", l.ClassificationsToInclude) populate(objectMap, "packageNameMasksToExclude", l.PackageNameMasksToExclude) populate(objectMap, "packageNameMasksToInclude", l.PackageNameMasksToInclude) @@ -1452,7 +1351,7 @@ func (l *LinuxParameters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MachineExtension. func (m MachineExtension) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "location", m.Location) populate(objectMap, "name", m.Name) @@ -1501,48 +1400,9 @@ func (m *MachineExtension) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type MachineExtensionInstanceView. -func (m MachineExtensionInstanceView) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "name", m.Name) - populate(objectMap, "status", m.Status) - populate(objectMap, "type", m.Type) - populate(objectMap, "typeHandlerVersion", m.TypeHandlerVersion) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MachineExtensionInstanceView. -func (m *MachineExtensionInstanceView) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "name": - err = unpopulate(val, "Name", &m.Name) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &m.Status) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &m.Type) - delete(rawMsg, key) - case "typeHandlerVersion": - err = unpopulate(val, "TypeHandlerVersion", &m.TypeHandlerVersion) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type MachineExtensionInstanceViewStatus. func (m MachineExtensionInstanceViewStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", m.Code) populate(objectMap, "displayStatus", m.DisplayStatus) populate(objectMap, "level", m.Level) @@ -1585,7 +1445,7 @@ func (m *MachineExtensionInstanceViewStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MachineExtensionProperties. func (m MachineExtensionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "autoUpgradeMinorVersion", m.AutoUpgradeMinorVersion) populate(objectMap, "enableAutomaticUpgrade", m.EnableAutomaticUpgrade) populate(objectMap, "forceUpdateTag", m.ForceUpdateTag) @@ -1648,7 +1508,7 @@ func (m *MachineExtensionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MachineExtensionPropertiesInstanceView. func (m MachineExtensionPropertiesInstanceView) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", m.Name) populate(objectMap, "status", m.Status) populate(objectMap, "type", m.Type) @@ -1687,7 +1547,7 @@ func (m *MachineExtensionPropertiesInstanceView) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type MachineExtensionUpdate. func (m MachineExtensionUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", m.Properties) populate(objectMap, "tags", m.Tags) return json.Marshal(objectMap) @@ -1718,7 +1578,7 @@ func (m *MachineExtensionUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MachineExtensionUpdateProperties. func (m MachineExtensionUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "autoUpgradeMinorVersion", m.AutoUpgradeMinorVersion) populate(objectMap, "enableAutomaticUpgrade", m.EnableAutomaticUpgrade) populate(objectMap, "forceUpdateTag", m.ForceUpdateTag) @@ -1773,7 +1633,7 @@ func (m *MachineExtensionUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MachineExtensionsListResult. func (m MachineExtensionsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -1804,7 +1664,7 @@ func (m *MachineExtensionsListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkInterface. func (n NetworkInterface) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceKey", n.DeviceKey) populate(objectMap, "ipAddresses", n.IPAddresses) populate(objectMap, "ipSettings", n.IPSettings) @@ -1871,7 +1731,7 @@ func (n *NetworkInterface) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkInterfaceUpdate. func (n NetworkInterfaceUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "deviceKey", n.DeviceKey) populate(objectMap, "name", n.Name) populate(objectMap, "networkId", n.NetworkID) @@ -1914,7 +1774,7 @@ func (n *NetworkInterfaceUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkProfile. func (n NetworkProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "networkInterfaces", n.NetworkInterfaces) return json.Marshal(objectMap) } @@ -1941,7 +1801,7 @@ func (n *NetworkProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkProfileUpdate. func (n NetworkProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "networkInterfaces", n.NetworkInterfaces) return json.Marshal(objectMap) } @@ -1968,7 +1828,7 @@ func (n *NetworkProfileUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NicIPAddressSettings. func (n NicIPAddressSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allocationMethod", n.AllocationMethod) populate(objectMap, "ipAddress", n.IPAddress) populate(objectMap, "subnetMask", n.SubnetMask) @@ -2003,7 +1863,7 @@ func (n *NicIPAddressSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NicIPSettings. func (n NicIPSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allocationMethod", n.AllocationMethod) populate(objectMap, "dnsServers", n.DNSServers) populate(objectMap, "gateway", n.Gateway) @@ -2058,7 +1918,7 @@ func (n *NicIPSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -2093,7 +1953,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -2132,7 +1992,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationsList. func (o OperationsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -2163,7 +2023,7 @@ func (o *OperationsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OsProfile. func (o OsProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "adminPassword", o.AdminPassword) populate(objectMap, "adminUsername", o.AdminUsername) populate(objectMap, "allowExtensionOperations", o.AllowExtensionOperations) @@ -2234,7 +2094,7 @@ func (o *OsProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OsProfileLinuxConfiguration. func (o OsProfileLinuxConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "patchSettings", o.PatchSettings) return json.Marshal(objectMap) } @@ -2261,7 +2121,7 @@ func (o *OsProfileLinuxConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OsProfileUpdate. func (o OsProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "linuxConfiguration", o.LinuxConfiguration) populate(objectMap, "windowsConfiguration", o.WindowsConfiguration) return json.Marshal(objectMap) @@ -2292,7 +2152,7 @@ func (o *OsProfileUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OsProfileUpdateLinuxConfiguration. func (o OsProfileUpdateLinuxConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "patchSettings", o.PatchSettings) return json.Marshal(objectMap) } @@ -2319,7 +2179,7 @@ func (o *OsProfileUpdateLinuxConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OsProfileUpdateWindowsConfiguration. func (o OsProfileUpdateWindowsConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "patchSettings", o.PatchSettings) return json.Marshal(objectMap) } @@ -2346,7 +2206,7 @@ func (o *OsProfileUpdateWindowsConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OsProfileWindowsConfiguration. func (o OsProfileWindowsConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "patchSettings", o.PatchSettings) return json.Marshal(objectMap) } @@ -2373,7 +2233,7 @@ func (o *OsProfileWindowsConfiguration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PatchSettings. func (p PatchSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentMode", p.AssessmentMode) populate(objectMap, "patchMode", p.PatchMode) return json.Marshal(objectMap) @@ -2404,7 +2264,7 @@ func (p *PatchSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PlacementProfile. func (p PlacementProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clusterId", p.ClusterID) populate(objectMap, "datastoreId", p.DatastoreID) populate(objectMap, "hostId", p.HostID) @@ -2441,79 +2301,9 @@ func (p *PlacementProfile) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ProxyResource. -func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. -func (p *ProxyResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ResourcePatch. func (r ResourcePatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", r.Tags) return json.Marshal(objectMap) } @@ -2540,7 +2330,7 @@ func (r *ResourcePatch) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourcePool. func (r ResourcePool) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", r.ExtendedLocation) populate(objectMap, "id", r.ID) populate(objectMap, "kind", r.Kind) @@ -2599,7 +2389,7 @@ func (r *ResourcePool) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourcePoolInventoryItem. func (r ResourcePoolInventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["inventoryType"] = InventoryTypeResourcePool populate(objectMap, "managedResourceId", r.ManagedResourceID) populate(objectMap, "moName", r.MoName) @@ -2646,7 +2436,7 @@ func (r *ResourcePoolInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourcePoolProperties. func (r ResourcePoolProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cpuLimitMHz", r.CPULimitMHz) populate(objectMap, "cpuReservationMHz", r.CPUReservationMHz) populate(objectMap, "cpuSharesLevel", r.CPUSharesLevel) @@ -2725,7 +2515,7 @@ func (r *ResourcePoolProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourcePoolsList. func (r ResourcePoolsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -2756,7 +2546,7 @@ func (r *ResourcePoolsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceStatus. func (r ResourceStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "lastUpdatedAt", r.LastUpdatedAt) populate(objectMap, "message", r.Message) populate(objectMap, "reason", r.Reason) @@ -2803,7 +2593,7 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SecurityProfile. func (s SecurityProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "uefiSettings", s.UefiSettings) return json.Marshal(objectMap) } @@ -2830,7 +2620,7 @@ func (s *SecurityProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StopVirtualMachineOptions. func (s StopVirtualMachineOptions) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "skipShutdown", s.SkipShutdown) return json.Marshal(objectMap) } @@ -2857,7 +2647,7 @@ func (s *StopVirtualMachineOptions) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageProfile. func (s StorageProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "disks", s.Disks) populate(objectMap, "scsiControllers", s.ScsiControllers) return json.Marshal(objectMap) @@ -2888,7 +2678,7 @@ func (s *StorageProfile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageProfileUpdate. func (s StorageProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "disks", s.Disks) return json.Marshal(objectMap) } @@ -2915,7 +2705,7 @@ func (s *StorageProfileUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -2962,7 +2752,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UefiSettings. func (u UefiSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "secureBootEnabled", u.SecureBootEnabled) return json.Marshal(objectMap) } @@ -2989,7 +2779,7 @@ func (u *UefiSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VCenter. func (v VCenter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", v.ExtendedLocation) populate(objectMap, "id", v.ID) populate(objectMap, "kind", v.Kind) @@ -3048,7 +2838,7 @@ func (v *VCenter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VCenterProperties. func (v VCenterProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionStatus", v.ConnectionStatus) populate(objectMap, "credentials", v.Credentials) populate(objectMap, "customResourceName", v.CustomResourceName) @@ -3111,7 +2901,7 @@ func (v *VCenterProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VCentersList. func (v VCentersList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -3142,7 +2932,7 @@ func (v *VCentersList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VICredential. func (v VICredential) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "password", v.Password) populate(objectMap, "username", v.Username) return json.Marshal(objectMap) @@ -3173,7 +2963,7 @@ func (v *VICredential) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualDisk. func (v VirtualDisk) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "controllerKey", v.ControllerKey) populate(objectMap, "deviceKey", v.DeviceKey) populate(objectMap, "deviceName", v.DeviceName) @@ -3236,7 +3026,7 @@ func (v *VirtualDisk) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualDiskUpdate. func (v VirtualDiskUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "controllerKey", v.ControllerKey) populate(objectMap, "deviceKey", v.DeviceKey) populate(objectMap, "deviceName", v.DeviceName) @@ -3291,7 +3081,7 @@ func (v *VirtualDiskUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachine. func (v VirtualMachine) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", v.ExtendedLocation) populate(objectMap, "id", v.ID) populate(objectMap, "identity", v.Identity) @@ -3354,7 +3144,7 @@ func (v *VirtualMachine) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineAssessPatchesResult. func (v VirtualMachineAssessPatchesResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "assessmentActivityId", v.AssessmentActivityID) populate(objectMap, "availablePatchCountByClassification", v.AvailablePatchCountByClassification) populate(objectMap, "errorDetails", v.ErrorDetails) @@ -3417,7 +3207,7 @@ func (v *VirtualMachineAssessPatchesResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstallPatchesParameters. func (v VirtualMachineInstallPatchesParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "linuxParameters", v.LinuxParameters) populate(objectMap, "maximumDuration", v.MaximumDuration) populate(objectMap, "rebootSetting", v.RebootSetting) @@ -3456,7 +3246,7 @@ func (v *VirtualMachineInstallPatchesParameters) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstallPatchesResult. func (v VirtualMachineInstallPatchesResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "errorDetails", v.ErrorDetails) populate(objectMap, "excludedPatchCount", v.ExcludedPatchCount) populate(objectMap, "failedPatchCount", v.FailedPatchCount) @@ -3539,7 +3329,7 @@ func (v *VirtualMachineInstallPatchesResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineInventoryItem. func (v VirtualMachineInventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "folderPath", v.FolderPath) populate(objectMap, "host", v.Host) populate(objectMap, "ipAddresses", v.IPAddresses) @@ -3630,7 +3420,7 @@ func (v *VirtualMachineInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineProperties. func (v VirtualMachineProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customResourceName", v.CustomResourceName) populate(objectMap, "firmwareType", v.FirmwareType) populate(objectMap, "folderPath", v.FolderPath) @@ -3745,7 +3535,7 @@ func (v *VirtualMachineProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplate. func (v VirtualMachineTemplate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", v.ExtendedLocation) populate(objectMap, "id", v.ID) populate(objectMap, "kind", v.Kind) @@ -3804,7 +3594,7 @@ func (v *VirtualMachineTemplate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplateInventoryItem. func (v VirtualMachineTemplateInventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "folderPath", v.FolderPath) objectMap["inventoryType"] = InventoryTypeVirtualMachineTemplate populate(objectMap, "managedResourceId", v.ManagedResourceID) @@ -3871,7 +3661,7 @@ func (v *VirtualMachineTemplateInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplateProperties. func (v VirtualMachineTemplateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customResourceName", v.CustomResourceName) populate(objectMap, "disks", v.Disks) populate(objectMap, "firmwareType", v.FirmwareType) @@ -3970,7 +3760,7 @@ func (v *VirtualMachineTemplateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplatesList. func (v VirtualMachineTemplatesList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -4001,7 +3791,7 @@ func (v *VirtualMachineTemplatesList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineUpdate. func (v VirtualMachineUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", v.Identity) populate(objectMap, "properties", v.Properties) populate(objectMap, "tags", v.Tags) @@ -4036,7 +3826,7 @@ func (v *VirtualMachineUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineUpdateProperties. func (v VirtualMachineUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "hardwareProfile", v.HardwareProfile) populate(objectMap, "networkProfile", v.NetworkProfile) populate(objectMap, "osProfile", v.OSProfile) @@ -4075,7 +3865,7 @@ func (v *VirtualMachineUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachinesList. func (v VirtualMachinesList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -4106,7 +3896,7 @@ func (v *VirtualMachinesList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetwork. func (v VirtualNetwork) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "extendedLocation", v.ExtendedLocation) populate(objectMap, "id", v.ID) populate(objectMap, "kind", v.Kind) @@ -4165,7 +3955,7 @@ func (v *VirtualNetwork) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkInventoryItem. func (v VirtualNetworkInventoryItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["inventoryType"] = InventoryTypeVirtualNetwork populate(objectMap, "managedResourceId", v.ManagedResourceID) populate(objectMap, "moName", v.MoName) @@ -4208,7 +3998,7 @@ func (v *VirtualNetworkInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkProperties. func (v VirtualNetworkProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customResourceName", v.CustomResourceName) populate(objectMap, "inventoryItemId", v.InventoryItemID) populate(objectMap, "moName", v.MoName) @@ -4263,7 +4053,7 @@ func (v *VirtualNetworkProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworksList. func (v VirtualNetworksList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -4294,7 +4084,7 @@ func (v *VirtualNetworksList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualSCSIController. func (v VirtualSCSIController) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "busNumber", v.BusNumber) populate(objectMap, "controllerKey", v.ControllerKey) populate(objectMap, "scsiCtlrUnitNumber", v.ScsiCtlrUnitNumber) @@ -4337,7 +4127,7 @@ func (v *VirtualSCSIController) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WindowsParameters. func (w WindowsParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "classificationsToInclude", w.ClassificationsToInclude) populate(objectMap, "excludeKbsRequiringReboot", w.ExcludeKbsRequiringReboot) populate(objectMap, "kbNumbersToExclude", w.KbNumbersToExclude) @@ -4378,7 +4168,7 @@ func (w *WindowsParameters) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -4388,7 +4178,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go index 6a64f76239f6..d78d71bc39e2 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go @@ -21,8 +21,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -31,36 +29,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Returns list of all operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -77,7 +66,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -92,7 +81,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.ConnectedVMwarevSphere/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go index 3d2e2104ad52..56b6b17746d6 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -16,26 +25,220 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListOperations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListOperations.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewOperationsClient(cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationsList = armconnectedvmware.OperationsList{ + // Value: []*armconnectedvmware.Operation{ + // { + // Name: to.Ptr("microsoft.vmware/vcenters/Read"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Read vcenters"), + // Operation: to.Ptr("Gets/List vcenters resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("vcenters"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/vcenters/Write"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Writes vcenters"), + // Operation: to.Ptr("Create/update vcenters resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("vcenters"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/vcenters/Delete"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Deletes vcenters"), + // Operation: to.Ptr("Deletes vcenters resource"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("vcenters"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/resourcepools/Read"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Read resourcepools"), + // Operation: to.Ptr("Gets/List resourcepools resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("resourcepools"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/resourcepools/Write"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Writes resourcepools"), + // Operation: to.Ptr("Create/update resourcepools resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("resourcepools"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/resourcepools/Delete"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Deletes resourcepools"), + // Operation: to.Ptr("Deletes resourcepools resource"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("resourcepools"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualmachines/Read"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Read virtualmachines"), + // Operation: to.Ptr("Gets/List virtualmachines resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualmachines"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualmachines/Write"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Writes virtualmachines"), + // Operation: to.Ptr("Create/update virtualmachines resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualmachines"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualmachines/Delete"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Deletes virtualmachines"), + // Operation: to.Ptr("Deletes virtualmachines resource"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualmachines"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/Read"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Read virtualmachinetemplates"), + // Operation: to.Ptr("Gets/List virtualmachinetemplates resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualmachinetemplates"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/Write"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Writes virtualmachinetemplates"), + // Operation: to.Ptr("Create/update virtualmachinetemplates resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualmachinetemplates"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/Delete"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Deletes virtualmachinetemplates"), + // Operation: to.Ptr("Deletes virtualmachinetemplates resource"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualmachinetemplates"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualnetworks/Read"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Read virtualnetworks"), + // Operation: to.Ptr("Gets/List virtualnetworks resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualnetworks"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualnetworks/Write"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Writes virtualnetworks"), + // Operation: to.Ptr("Create/update virtualnetworks resources"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualnetworks"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualnetworks/Delete"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Deletes virtualnetworks"), + // Operation: to.Ptr("Deletes virtualnetworks resource"), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualnetworks"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/arczones/deploy/action"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Deploy on arczone."), + // Operation: to.Ptr("Deploy on arczone."), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("arczones"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/clone/action"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Clone on virtual machine templates."), + // Operation: to.Ptr("Clone on virtual machine templates."), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualmachinetemplates"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/resourcepools/deploy/action"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Deploy on resource pool."), + // Operation: to.Ptr("Deploy on resource pool."), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("resourcepools"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("microsoft.vmware/virtualnetworks/join/action"), + // Display: &armconnectedvmware.OperationDisplay{ + // Description: to.Ptr("Join virtual network."), + // Operation: to.Ptr("Join virtual network."), + // Provider: to.Ptr("microsoft.vmware"), + // Resource: to.Ptr("virtualnetworks"), + // }, + // IsDataAction: to.Ptr(false), + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go index 0cf0ab7fca33..6ddcdb956204 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go @@ -23,7 +23,7 @@ func unmarshalInventoryItemPropertiesClassification(rawMsg json.RawMessage) (Inv if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go index c027d9ec21c7..ebf98b49017e 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,66 +33,59 @@ import ( // ResourcePoolsClient contains the methods for the ResourcePools group. // Don't use this type directly, use NewResourcePoolsClient() instead. type ResourcePoolsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewResourcePoolsClient creates a new instance of ResourcePoolsClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewResourcePoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourcePoolsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ResourcePoolsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourcePoolsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update resourcePool. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// resourcePoolName - Name of the resourcePool. -// body - Request payload. -// options - ResourcePoolsClientBeginCreateOptions contains the optional parameters for the ResourcePoolsClient.BeginCreate -// method. +// - resourceGroupName - The Resource Group Name. +// - resourcePoolName - Name of the resourcePool. +// - body - Request payload. +// - options - ResourcePoolsClientBeginCreateOptions contains the optional parameters for the ResourcePoolsClient.BeginCreate +// method. func (client *ResourcePoolsClient) BeginCreate(ctx context.Context, resourceGroupName string, resourcePoolName string, body ResourcePool, options *ResourcePoolsClientBeginCreateOptions) (*runtime.Poller[ResourcePoolsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, resourcePoolName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ResourcePoolsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourcePoolsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ResourcePoolsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ResourcePoolsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update resourcePool. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *ResourcePoolsClient) create(ctx context.Context, resourceGroupName string, resourcePoolName string, body ResourcePool, options *ResourcePoolsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, resourcePoolName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -119,7 +110,7 @@ func (client *ResourcePoolsClient) createCreateRequest(ctx context.Context, reso return nil, errors.New("parameter resourcePoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourcePoolName}", url.PathEscape(resourcePoolName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -132,32 +123,34 @@ func (client *ResourcePoolsClient) createCreateRequest(ctx context.Context, reso // BeginDelete - Implements resourcePool DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// resourcePoolName - Name of the resourcePool. -// options - ResourcePoolsClientBeginDeleteOptions contains the optional parameters for the ResourcePoolsClient.BeginDelete -// method. +// - resourceGroupName - The Resource Group Name. +// - resourcePoolName - Name of the resourcePool. +// - options - ResourcePoolsClientBeginDeleteOptions contains the optional parameters for the ResourcePoolsClient.BeginDelete +// method. func (client *ResourcePoolsClient) BeginDelete(ctx context.Context, resourceGroupName string, resourcePoolName string, options *ResourcePoolsClientBeginDeleteOptions) (*runtime.Poller[ResourcePoolsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, resourcePoolName, options) if err != nil { return nil, err } - return runtime.NewPoller[ResourcePoolsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ResourcePoolsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ResourcePoolsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ResourcePoolsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements resourcePool DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *ResourcePoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourcePoolName string, options *ResourcePoolsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourcePoolName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -182,7 +175,7 @@ func (client *ResourcePoolsClient) deleteCreateRequest(ctx context.Context, reso return nil, errors.New("parameter resourcePoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourcePoolName}", url.PathEscape(resourcePoolName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,16 +191,17 @@ func (client *ResourcePoolsClient) deleteCreateRequest(ctx context.Context, reso // Get - Implements resourcePool GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// resourcePoolName - Name of the resourcePool. -// options - ResourcePoolsClientGetOptions contains the optional parameters for the ResourcePoolsClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - resourcePoolName - Name of the resourcePool. +// - options - ResourcePoolsClientGetOptions contains the optional parameters for the ResourcePoolsClient.Get method. func (client *ResourcePoolsClient) Get(ctx context.Context, resourceGroupName string, resourcePoolName string, options *ResourcePoolsClientGetOptions) (ResourcePoolsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourcePoolName, options) if err != nil { return ResourcePoolsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientGetResponse{}, err } @@ -232,7 +226,7 @@ func (client *ResourcePoolsClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter resourcePoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourcePoolName}", url.PathEscape(resourcePoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,9 +247,9 @@ func (client *ResourcePoolsClient) getHandleResponse(resp *http.Response) (Resou } // NewListPager - List of resourcePools in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.List method. +// - options - ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.NewListPager method. func (client *ResourcePoolsClient) NewListPager(options *ResourcePoolsClientListOptions) *runtime.Pager[ResourcePoolsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourcePoolsClientListResponse]{ More: func(page ResourcePoolsClientListResponse) bool { @@ -272,7 +266,7 @@ func (client *ResourcePoolsClient) NewListPager(options *ResourcePoolsClientList if err != nil { return ResourcePoolsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientListResponse{}, err } @@ -291,7 +285,7 @@ func (client *ResourcePoolsClient) listCreateRequest(ctx context.Context, option return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -312,11 +306,11 @@ func (client *ResourcePoolsClient) listHandleResponse(resp *http.Response) (Reso } // NewListByResourceGroupPager - List of resourcePools in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - ResourcePoolsClientListByResourceGroupOptions contains the optional parameters for the ResourcePoolsClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - ResourcePoolsClientListByResourceGroupOptions contains the optional parameters for the ResourcePoolsClient.NewListByResourceGroupPager +// method. func (client *ResourcePoolsClient) NewListByResourceGroupPager(resourceGroupName string, options *ResourcePoolsClientListByResourceGroupOptions) *runtime.Pager[ResourcePoolsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ResourcePoolsClientListByResourceGroupResponse]{ More: func(page ResourcePoolsClientListByResourceGroupResponse) bool { @@ -333,7 +327,7 @@ func (client *ResourcePoolsClient) NewListByResourceGroupPager(resourceGroupName if err != nil { return ResourcePoolsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientListByResourceGroupResponse{}, err } @@ -356,7 +350,7 @@ func (client *ResourcePoolsClient) listByResourceGroupCreateRequest(ctx context. return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -378,17 +372,18 @@ func (client *ResourcePoolsClient) listByResourceGroupHandleResponse(resp *http. // Update - API to update certain properties of the resourcePool resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// resourcePoolName - Name of the resourcePool. -// body - Resource properties to update. -// options - ResourcePoolsClientUpdateOptions contains the optional parameters for the ResourcePoolsClient.Update method. +// - resourceGroupName - The Resource Group Name. +// - resourcePoolName - Name of the resourcePool. +// - body - Resource properties to update. +// - options - ResourcePoolsClientUpdateOptions contains the optional parameters for the ResourcePoolsClient.Update method. func (client *ResourcePoolsClient) Update(ctx context.Context, resourceGroupName string, resourcePoolName string, body ResourcePatch, options *ResourcePoolsClientUpdateOptions) (ResourcePoolsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourcePoolName, body, options) if err != nil { return ResourcePoolsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientUpdateResponse{}, err } @@ -413,7 +408,7 @@ func (client *ResourcePoolsClient) updateCreateRequest(ctx context.Context, reso return nil, errors.New("parameter resourcePoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourcePoolName}", url.PathEscape(resourcePoolName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go index 8a73ac463f67..3654937b6ba4 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateResourcePool.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateResourcePool.json func ExampleResourcePoolsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewResourcePoolsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "HRPool", armconnectedvmware.ResourcePool{ + poller, err := clientFactory.NewResourcePoolsClient().BeginCreate(ctx, "testrg", "HRPool", armconnectedvmware.ResourcePool{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -46,41 +55,73 @@ func ExampleResourcePoolsClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourcePool = armconnectedvmware.ResourcePool{ + // Name: to.Ptr("HRPool"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ResourcePoolProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetResourcePool.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetResourcePool.json func ExampleResourcePoolsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewResourcePoolsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "HRPool", nil) + res, err := clientFactory.NewResourcePoolsClient().Get(ctx, "testrg", "HRPool", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourcePool = armconnectedvmware.ResourcePool{ + // Name: to.Ptr("HRPool"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ResourcePoolProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateResourcePool.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateResourcePool.json func ExampleResourcePoolsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewResourcePoolsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "testrg", "HRPool", armconnectedvmware.ResourcePatch{ + res, err := clientFactory.NewResourcePoolsClient().Update(ctx, "testrg", "HRPool", armconnectedvmware.ResourcePatch{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -89,22 +130,42 @@ func ExampleResourcePoolsClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ResourcePool = armconnectedvmware.ResourcePool{ + // Name: to.Ptr("HRPool"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ResourcePoolProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteResourcePool.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteResourcePool.json func ExampleResourcePoolsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewResourcePoolsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "HRPool", &armconnectedvmware.ResourcePoolsClientBeginDeleteOptions{Force: nil}) + poller, err := clientFactory.NewResourcePoolsClient().BeginDelete(ctx, "testrg", "HRPool", &armconnectedvmware.ResourcePoolsClientBeginDeleteOptions{Force: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -114,50 +175,88 @@ func ExampleResourcePoolsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListResourcePools.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListResourcePools.json func ExampleResourcePoolsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewResourcePoolsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewResourcePoolsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ResourcePoolsList = armconnectedvmware.ResourcePoolsList{ + // Value: []*armconnectedvmware.ResourcePool{ + // { + // Name: to.Ptr("HRPool"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ResourcePoolProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListResourcePoolsByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListResourcePoolsByResourceGroup.json func ExampleResourcePoolsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewResourcePoolsClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewResourcePoolsClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ResourcePoolsList = armconnectedvmware.ResourcePoolsList{ + // Value: []*armconnectedvmware.ResourcePool{ + // { + // Name: to.Ptr("HRPool"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.ResourcePoolProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go index fc236dd6d256..a2f8bbf005a1 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go @@ -17,12 +17,12 @@ package armconnectedvmware -// ClustersClientCreateResponse contains the response from method ClustersClient.Create. +// ClustersClientCreateResponse contains the response from method ClustersClient.BeginCreate. type ClustersClientCreateResponse struct { Cluster } -// ClustersClientDeleteResponse contains the response from method ClustersClient.Delete. +// ClustersClientDeleteResponse contains the response from method ClustersClient.BeginDelete. type ClustersClientDeleteResponse struct { // placeholder for future response values } @@ -32,12 +32,12 @@ type ClustersClientGetResponse struct { Cluster } -// ClustersClientListByResourceGroupResponse contains the response from method ClustersClient.ListByResourceGroup. +// ClustersClientListByResourceGroupResponse contains the response from method ClustersClient.NewListByResourceGroupPager. type ClustersClientListByResourceGroupResponse struct { ClustersList } -// ClustersClientListResponse contains the response from method ClustersClient.List. +// ClustersClientListResponse contains the response from method ClustersClient.NewListPager. type ClustersClientListResponse struct { ClustersList } @@ -47,12 +47,12 @@ type ClustersClientUpdateResponse struct { Cluster } -// DatastoresClientCreateResponse contains the response from method DatastoresClient.Create. +// DatastoresClientCreateResponse contains the response from method DatastoresClient.BeginCreate. type DatastoresClientCreateResponse struct { Datastore } -// DatastoresClientDeleteResponse contains the response from method DatastoresClient.Delete. +// DatastoresClientDeleteResponse contains the response from method DatastoresClient.BeginDelete. type DatastoresClientDeleteResponse struct { // placeholder for future response values } @@ -62,12 +62,12 @@ type DatastoresClientGetResponse struct { Datastore } -// DatastoresClientListByResourceGroupResponse contains the response from method DatastoresClient.ListByResourceGroup. +// DatastoresClientListByResourceGroupResponse contains the response from method DatastoresClient.NewListByResourceGroupPager. type DatastoresClientListByResourceGroupResponse struct { DatastoresList } -// DatastoresClientListResponse contains the response from method DatastoresClient.List. +// DatastoresClientListResponse contains the response from method DatastoresClient.NewListPager. type DatastoresClientListResponse struct { DatastoresList } @@ -77,12 +77,12 @@ type DatastoresClientUpdateResponse struct { Datastore } -// GuestAgentsClientCreateResponse contains the response from method GuestAgentsClient.Create. +// GuestAgentsClientCreateResponse contains the response from method GuestAgentsClient.BeginCreate. type GuestAgentsClientCreateResponse struct { GuestAgent } -// GuestAgentsClientDeleteResponse contains the response from method GuestAgentsClient.Delete. +// GuestAgentsClientDeleteResponse contains the response from method GuestAgentsClient.BeginDelete. type GuestAgentsClientDeleteResponse struct { // placeholder for future response values } @@ -92,17 +92,17 @@ type GuestAgentsClientGetResponse struct { GuestAgent } -// GuestAgentsClientListByVMResponse contains the response from method GuestAgentsClient.ListByVM. +// GuestAgentsClientListByVMResponse contains the response from method GuestAgentsClient.NewListByVMPager. type GuestAgentsClientListByVMResponse struct { GuestAgentList } -// HostsClientCreateResponse contains the response from method HostsClient.Create. +// HostsClientCreateResponse contains the response from method HostsClient.BeginCreate. type HostsClientCreateResponse struct { Host } -// HostsClientDeleteResponse contains the response from method HostsClient.Delete. +// HostsClientDeleteResponse contains the response from method HostsClient.BeginDelete. type HostsClientDeleteResponse struct { // placeholder for future response values } @@ -112,12 +112,12 @@ type HostsClientGetResponse struct { Host } -// HostsClientListByResourceGroupResponse contains the response from method HostsClient.ListByResourceGroup. +// HostsClientListByResourceGroupResponse contains the response from method HostsClient.NewListByResourceGroupPager. type HostsClientListByResourceGroupResponse struct { HostsList } -// HostsClientListResponse contains the response from method HostsClient.List. +// HostsClientListResponse contains the response from method HostsClient.NewListPager. type HostsClientListResponse struct { HostsList } @@ -142,7 +142,7 @@ type HybridIdentityMetadataClientGetResponse struct { HybridIdentityMetadata } -// HybridIdentityMetadataClientListByVMResponse contains the response from method HybridIdentityMetadataClient.ListByVM. +// HybridIdentityMetadataClientListByVMResponse contains the response from method HybridIdentityMetadataClient.NewListByVMPager. type HybridIdentityMetadataClientListByVMResponse struct { HybridIdentityMetadataList } @@ -162,17 +162,17 @@ type InventoryItemsClientGetResponse struct { InventoryItem } -// InventoryItemsClientListByVCenterResponse contains the response from method InventoryItemsClient.ListByVCenter. +// InventoryItemsClientListByVCenterResponse contains the response from method InventoryItemsClient.NewListByVCenterPager. type InventoryItemsClientListByVCenterResponse struct { InventoryItemsList } -// MachineExtensionsClientCreateOrUpdateResponse contains the response from method MachineExtensionsClient.CreateOrUpdate. +// MachineExtensionsClientCreateOrUpdateResponse contains the response from method MachineExtensionsClient.BeginCreateOrUpdate. type MachineExtensionsClientCreateOrUpdateResponse struct { MachineExtension } -// MachineExtensionsClientDeleteResponse contains the response from method MachineExtensionsClient.Delete. +// MachineExtensionsClientDeleteResponse contains the response from method MachineExtensionsClient.BeginDelete. type MachineExtensionsClientDeleteResponse struct { // placeholder for future response values } @@ -182,27 +182,27 @@ type MachineExtensionsClientGetResponse struct { MachineExtension } -// MachineExtensionsClientListResponse contains the response from method MachineExtensionsClient.List. +// MachineExtensionsClientListResponse contains the response from method MachineExtensionsClient.NewListPager. type MachineExtensionsClientListResponse struct { MachineExtensionsListResult } -// MachineExtensionsClientUpdateResponse contains the response from method MachineExtensionsClient.Update. +// MachineExtensionsClientUpdateResponse contains the response from method MachineExtensionsClient.BeginUpdate. type MachineExtensionsClientUpdateResponse struct { MachineExtension } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationsList } -// ResourcePoolsClientCreateResponse contains the response from method ResourcePoolsClient.Create. +// ResourcePoolsClientCreateResponse contains the response from method ResourcePoolsClient.BeginCreate. type ResourcePoolsClientCreateResponse struct { ResourcePool } -// ResourcePoolsClientDeleteResponse contains the response from method ResourcePoolsClient.Delete. +// ResourcePoolsClientDeleteResponse contains the response from method ResourcePoolsClient.BeginDelete. type ResourcePoolsClientDeleteResponse struct { // placeholder for future response values } @@ -212,12 +212,12 @@ type ResourcePoolsClientGetResponse struct { ResourcePool } -// ResourcePoolsClientListByResourceGroupResponse contains the response from method ResourcePoolsClient.ListByResourceGroup. +// ResourcePoolsClientListByResourceGroupResponse contains the response from method ResourcePoolsClient.NewListByResourceGroupPager. type ResourcePoolsClientListByResourceGroupResponse struct { ResourcePoolsList } -// ResourcePoolsClientListResponse contains the response from method ResourcePoolsClient.List. +// ResourcePoolsClientListResponse contains the response from method ResourcePoolsClient.NewListPager. type ResourcePoolsClientListResponse struct { ResourcePoolsList } @@ -227,12 +227,12 @@ type ResourcePoolsClientUpdateResponse struct { ResourcePool } -// VCentersClientCreateResponse contains the response from method VCentersClient.Create. +// VCentersClientCreateResponse contains the response from method VCentersClient.BeginCreate. type VCentersClientCreateResponse struct { VCenter } -// VCentersClientDeleteResponse contains the response from method VCentersClient.Delete. +// VCentersClientDeleteResponse contains the response from method VCentersClient.BeginDelete. type VCentersClientDeleteResponse struct { // placeholder for future response values } @@ -242,12 +242,12 @@ type VCentersClientGetResponse struct { VCenter } -// VCentersClientListByResourceGroupResponse contains the response from method VCentersClient.ListByResourceGroup. +// VCentersClientListByResourceGroupResponse contains the response from method VCentersClient.NewListByResourceGroupPager. type VCentersClientListByResourceGroupResponse struct { VCentersList } -// VCentersClientListResponse contains the response from method VCentersClient.List. +// VCentersClientListResponse contains the response from method VCentersClient.NewListPager. type VCentersClientListResponse struct { VCentersList } @@ -257,12 +257,12 @@ type VCentersClientUpdateResponse struct { VCenter } -// VirtualMachineTemplatesClientCreateResponse contains the response from method VirtualMachineTemplatesClient.Create. +// VirtualMachineTemplatesClientCreateResponse contains the response from method VirtualMachineTemplatesClient.BeginCreate. type VirtualMachineTemplatesClientCreateResponse struct { VirtualMachineTemplate } -// VirtualMachineTemplatesClientDeleteResponse contains the response from method VirtualMachineTemplatesClient.Delete. +// VirtualMachineTemplatesClientDeleteResponse contains the response from method VirtualMachineTemplatesClient.BeginDelete. type VirtualMachineTemplatesClientDeleteResponse struct { // placeholder for future response values } @@ -272,12 +272,12 @@ type VirtualMachineTemplatesClientGetResponse struct { VirtualMachineTemplate } -// VirtualMachineTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineTemplatesClient.ListByResourceGroup. +// VirtualMachineTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineTemplatesClient.NewListByResourceGroupPager. type VirtualMachineTemplatesClientListByResourceGroupResponse struct { VirtualMachineTemplatesList } -// VirtualMachineTemplatesClientListResponse contains the response from method VirtualMachineTemplatesClient.List. +// VirtualMachineTemplatesClientListResponse contains the response from method VirtualMachineTemplatesClient.NewListPager. type VirtualMachineTemplatesClientListResponse struct { VirtualMachineTemplatesList } @@ -287,17 +287,17 @@ type VirtualMachineTemplatesClientUpdateResponse struct { VirtualMachineTemplate } -// VirtualMachinesClientAssessPatchesResponse contains the response from method VirtualMachinesClient.AssessPatches. +// VirtualMachinesClientAssessPatchesResponse contains the response from method VirtualMachinesClient.BeginAssessPatches. type VirtualMachinesClientAssessPatchesResponse struct { VirtualMachineAssessPatchesResult } -// VirtualMachinesClientCreateResponse contains the response from method VirtualMachinesClient.Create. +// VirtualMachinesClientCreateResponse contains the response from method VirtualMachinesClient.BeginCreate. type VirtualMachinesClientCreateResponse struct { VirtualMachine } -// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.Delete. +// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.BeginDelete. type VirtualMachinesClientDeleteResponse struct { // placeholder for future response values } @@ -307,47 +307,47 @@ type VirtualMachinesClientGetResponse struct { VirtualMachine } -// VirtualMachinesClientInstallPatchesResponse contains the response from method VirtualMachinesClient.InstallPatches. +// VirtualMachinesClientInstallPatchesResponse contains the response from method VirtualMachinesClient.BeginInstallPatches. type VirtualMachinesClientInstallPatchesResponse struct { VirtualMachineInstallPatchesResult } -// VirtualMachinesClientListByResourceGroupResponse contains the response from method VirtualMachinesClient.ListByResourceGroup. +// VirtualMachinesClientListByResourceGroupResponse contains the response from method VirtualMachinesClient.NewListByResourceGroupPager. type VirtualMachinesClientListByResourceGroupResponse struct { VirtualMachinesList } -// VirtualMachinesClientListResponse contains the response from method VirtualMachinesClient.List. +// VirtualMachinesClientListResponse contains the response from method VirtualMachinesClient.NewListPager. type VirtualMachinesClientListResponse struct { VirtualMachinesList } -// VirtualMachinesClientRestartResponse contains the response from method VirtualMachinesClient.Restart. +// VirtualMachinesClientRestartResponse contains the response from method VirtualMachinesClient.BeginRestart. type VirtualMachinesClientRestartResponse struct { // placeholder for future response values } -// VirtualMachinesClientStartResponse contains the response from method VirtualMachinesClient.Start. +// VirtualMachinesClientStartResponse contains the response from method VirtualMachinesClient.BeginStart. type VirtualMachinesClientStartResponse struct { // placeholder for future response values } -// VirtualMachinesClientStopResponse contains the response from method VirtualMachinesClient.Stop. +// VirtualMachinesClientStopResponse contains the response from method VirtualMachinesClient.BeginStop. type VirtualMachinesClientStopResponse struct { // placeholder for future response values } -// VirtualMachinesClientUpdateResponse contains the response from method VirtualMachinesClient.Update. +// VirtualMachinesClientUpdateResponse contains the response from method VirtualMachinesClient.BeginUpdate. type VirtualMachinesClientUpdateResponse struct { VirtualMachine } -// VirtualNetworksClientCreateResponse contains the response from method VirtualNetworksClient.Create. +// VirtualNetworksClientCreateResponse contains the response from method VirtualNetworksClient.BeginCreate. type VirtualNetworksClientCreateResponse struct { VirtualNetwork } -// VirtualNetworksClientDeleteResponse contains the response from method VirtualNetworksClient.Delete. +// VirtualNetworksClientDeleteResponse contains the response from method VirtualNetworksClient.BeginDelete. type VirtualNetworksClientDeleteResponse struct { // placeholder for future response values } @@ -357,12 +357,12 @@ type VirtualNetworksClientGetResponse struct { VirtualNetwork } -// VirtualNetworksClientListByResourceGroupResponse contains the response from method VirtualNetworksClient.ListByResourceGroup. +// VirtualNetworksClientListByResourceGroupResponse contains the response from method VirtualNetworksClient.NewListByResourceGroupPager. type VirtualNetworksClientListByResourceGroupResponse struct { VirtualNetworksList } -// VirtualNetworksClientListResponse contains the response from method VirtualNetworksClient.List. +// VirtualNetworksClientListResponse contains the response from method VirtualNetworksClient.NewListPager. type VirtualNetworksClientListResponse struct { VirtualNetworksList } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go index 83070261c7aa..6cfa8035aab1 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go @@ -70,7 +70,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go index bcc7f181bace..585a1529cac9 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,65 +33,58 @@ import ( // VCentersClient contains the methods for the VCenters group. // Don't use this type directly, use NewVCentersClient() instead. type VCentersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVCentersClient creates a new instance of VCentersClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVCentersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VCentersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VCentersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VCentersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update vCenter. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// body - Request payload. -// options - VCentersClientBeginCreateOptions contains the optional parameters for the VCentersClient.BeginCreate method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - body - Request payload. +// - options - VCentersClientBeginCreateOptions contains the optional parameters for the VCentersClient.BeginCreate method. func (client *VCentersClient) BeginCreate(ctx context.Context, resourceGroupName string, vcenterName string, body VCenter, options *VCentersClientBeginCreateOptions) (*runtime.Poller[VCentersClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, vcenterName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VCentersClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VCentersClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VCentersClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VCentersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update vCenter. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VCentersClient) create(ctx context.Context, resourceGroupName string, vcenterName string, body VCenter, options *VCentersClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, vcenterName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -118,7 +109,7 @@ func (client *VCentersClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter vcenterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vcenterName}", url.PathEscape(vcenterName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -131,31 +122,33 @@ func (client *VCentersClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Implements vCenter DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// options - VCentersClientBeginDeleteOptions contains the optional parameters for the VCentersClient.BeginDelete method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - options - VCentersClientBeginDeleteOptions contains the optional parameters for the VCentersClient.BeginDelete method. func (client *VCentersClient) BeginDelete(ctx context.Context, resourceGroupName string, vcenterName string, options *VCentersClientBeginDeleteOptions) (*runtime.Poller[VCentersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, vcenterName, options) if err != nil { return nil, err } - return runtime.NewPoller[VCentersClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VCentersClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VCentersClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VCentersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements vCenter DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VCentersClient) deleteOperation(ctx context.Context, resourceGroupName string, vcenterName string, options *VCentersClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, vcenterName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +173,7 @@ func (client *VCentersClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter vcenterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vcenterName}", url.PathEscape(vcenterName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -196,16 +189,17 @@ func (client *VCentersClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Implements vCenter GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// options - VCentersClientGetOptions contains the optional parameters for the VCentersClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - options - VCentersClientGetOptions contains the optional parameters for the VCentersClient.Get method. func (client *VCentersClient) Get(ctx context.Context, resourceGroupName string, vcenterName string, options *VCentersClientGetOptions) (VCentersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, vcenterName, options) if err != nil { return VCentersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VCentersClientGetResponse{}, err } @@ -230,7 +224,7 @@ func (client *VCentersClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter vcenterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vcenterName}", url.PathEscape(vcenterName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -251,9 +245,9 @@ func (client *VCentersClient) getHandleResponse(resp *http.Response) (VCentersCl } // NewListPager - List of vCenters in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - VCentersClientListOptions contains the optional parameters for the VCentersClient.List method. +// - options - VCentersClientListOptions contains the optional parameters for the VCentersClient.NewListPager method. func (client *VCentersClient) NewListPager(options *VCentersClientListOptions) *runtime.Pager[VCentersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VCentersClientListResponse]{ More: func(page VCentersClientListResponse) bool { @@ -270,7 +264,7 @@ func (client *VCentersClient) NewListPager(options *VCentersClientListOptions) * if err != nil { return VCentersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VCentersClientListResponse{}, err } @@ -289,7 +283,7 @@ func (client *VCentersClient) listCreateRequest(ctx context.Context, options *VC return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -310,11 +304,11 @@ func (client *VCentersClient) listHandleResponse(resp *http.Response) (VCentersC } // NewListByResourceGroupPager - List of vCenters in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - VCentersClientListByResourceGroupOptions contains the optional parameters for the VCentersClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - VCentersClientListByResourceGroupOptions contains the optional parameters for the VCentersClient.NewListByResourceGroupPager +// method. func (client *VCentersClient) NewListByResourceGroupPager(resourceGroupName string, options *VCentersClientListByResourceGroupOptions) *runtime.Pager[VCentersClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[VCentersClientListByResourceGroupResponse]{ More: func(page VCentersClientListByResourceGroupResponse) bool { @@ -331,7 +325,7 @@ func (client *VCentersClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return VCentersClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VCentersClientListByResourceGroupResponse{}, err } @@ -354,7 +348,7 @@ func (client *VCentersClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -376,17 +370,18 @@ func (client *VCentersClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - API to update certain properties of the vCenter resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// vcenterName - Name of the vCenter. -// body - Resource properties to update. -// options - VCentersClientUpdateOptions contains the optional parameters for the VCentersClient.Update method. +// - resourceGroupName - The Resource Group Name. +// - vcenterName - Name of the vCenter. +// - body - Resource properties to update. +// - options - VCentersClientUpdateOptions contains the optional parameters for the VCentersClient.Update method. func (client *VCentersClient) Update(ctx context.Context, resourceGroupName string, vcenterName string, body ResourcePatch, options *VCentersClientUpdateOptions) (VCentersClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, vcenterName, body, options) if err != nil { return VCentersClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VCentersClientUpdateResponse{}, err } @@ -411,7 +406,7 @@ func (client *VCentersClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter vcenterName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vcenterName}", url.PathEscape(vcenterName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go index 73648ad86358..db5c8b7760bc 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVCenter.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVCenter.json func ExampleVCentersClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVCentersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "ContosoVCenter", armconnectedvmware.VCenter{ + poller, err := clientFactory.NewVCentersClient().BeginCreate(ctx, "testrg", "ContosoVCenter", armconnectedvmware.VCenter{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -50,41 +59,83 @@ func ExampleVCentersClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VCenter = armconnectedvmware.VCenter{ + // Name: to.Ptr("ContosoVCenter"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VCenterProperties{ + // Credentials: &armconnectedvmware.VICredential{ + // Username: to.Ptr("tempuser"), + // }, + // Fqdn: to.Ptr("ContosoVMware.contoso.com"), + // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // Port: to.Ptr[int32](1234), + // ProvisioningState: to.Ptr("Succeeded"), + // Version: to.Ptr("1.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVCenter.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVCenter.json func ExampleVCentersClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVCentersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "ContosoVCenter", nil) + res, err := clientFactory.NewVCentersClient().Get(ctx, "testrg", "ContosoVCenter", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VCenter = armconnectedvmware.VCenter{ + // Name: to.Ptr("ContosoVCenter"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VCenterProperties{ + // Credentials: &armconnectedvmware.VICredential{ + // Username: to.Ptr("tempuser"), + // }, + // Fqdn: to.Ptr("ContosoVMware.contoso.com"), + // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // Port: to.Ptr[int32](1234), + // ProvisioningState: to.Ptr("Succeeded"), + // Version: to.Ptr("1.0"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVCenter.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVCenter.json func ExampleVCentersClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVCentersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "testrg", "ContosoVCenter", armconnectedvmware.ResourcePatch{ + res, err := clientFactory.NewVCentersClient().Update(ctx, "testrg", "ContosoVCenter", armconnectedvmware.ResourcePatch{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -93,22 +144,47 @@ func ExampleVCentersClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VCenter = armconnectedvmware.VCenter{ + // Name: to.Ptr("ContosoVCenter"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VCenterProperties{ + // Credentials: &armconnectedvmware.VICredential{ + // Username: to.Ptr("tempuser"), + // }, + // Fqdn: to.Ptr("ContosoVMware.contoso.com"), + // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // Port: to.Ptr[int32](1234), + // ProvisioningState: to.Ptr("Succeeded"), + // Version: to.Ptr("1.0"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVCenter.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVCenter.json func ExampleVCentersClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVCentersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "ContosoVCenter", &armconnectedvmware.VCentersClientBeginDeleteOptions{Force: nil}) + poller, err := clientFactory.NewVCentersClient().BeginDelete(ctx, "testrg", "ContosoVCenter", &armconnectedvmware.VCentersClientBeginDeleteOptions{Force: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -118,50 +194,98 @@ func ExampleVCentersClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVCenters.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVCenters.json func ExampleVCentersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVCentersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewVCentersClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VCentersList = armconnectedvmware.VCentersList{ + // Value: []*armconnectedvmware.VCenter{ + // { + // Name: to.Ptr("ContosoVCenter"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VCenterProperties{ + // Credentials: &armconnectedvmware.VICredential{ + // Username: to.Ptr("tempuser"), + // }, + // Fqdn: to.Ptr("ContosoVMware.contoso.com"), + // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // Port: to.Ptr[int32](1234), + // ProvisioningState: to.Ptr("Succeeded"), + // Version: to.Ptr("1.0"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVCentersByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVCentersByResourceGroup.json func ExampleVCentersClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVCentersClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewVCentersClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VCentersList = armconnectedvmware.VCentersList{ + // Value: []*armconnectedvmware.VCenter{ + // { + // Name: to.Ptr("ContosoVCenter"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VCenterProperties{ + // Credentials: &armconnectedvmware.VICredential{ + // Username: to.Ptr("tempuser"), + // }, + // Fqdn: to.Ptr("ContosoVMware.contoso.com"), + // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // Port: to.Ptr[int32](1234), + // ProvisioningState: to.Ptr("Succeeded"), + // Version: to.Ptr("1.0"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go index e91233a3d629..559fc6a1aa7e 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,65 +33,58 @@ import ( // VirtualMachinesClient contains the methods for the VirtualMachines group. // Don't use this type directly, use NewVirtualMachinesClient() instead. type VirtualMachinesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualMachinesClient creates a new instance of VirtualMachinesClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachinesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VirtualMachinesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualMachinesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginAssessPatches - The operation to assess patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The name of the resource group. -// name - The name of the vSphere VMware machine. -// options - VirtualMachinesClientBeginAssessPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginAssessPatches -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the vSphere VMware machine. +// - options - VirtualMachinesClientBeginAssessPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginAssessPatches +// method. func (client *VirtualMachinesClient) BeginAssessPatches(ctx context.Context, resourceGroupName string, name string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*runtime.Poller[VirtualMachinesClientAssessPatchesResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.assessPatches(ctx, resourceGroupName, name, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachinesClientAssessPatchesResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientAssessPatchesResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientAssessPatchesResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientAssessPatchesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // AssessPatches - The operation to assess patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) assessPatches(ctx context.Context, resourceGroupName string, name string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*http.Response, error) { req, err := client.assessPatchesCreateRequest(ctx, resourceGroupName, name, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -118,7 +109,7 @@ func (client *VirtualMachinesClient) assessPatchesCreateRequest(ctx context.Cont return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -131,35 +122,37 @@ func (client *VirtualMachinesClient) assessPatchesCreateRequest(ctx context.Cont // BeginCreate - Create Or Update virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the virtual machine resource. -// body - Request payload. -// options - VirtualMachinesClientBeginCreateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreate -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the virtual machine resource. +// - body - Request payload. +// - options - VirtualMachinesClientBeginCreateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreate +// method. func (client *VirtualMachinesClient) BeginCreate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOptions) (*runtime.Poller[VirtualMachinesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, virtualMachineName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachinesClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) create(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -184,7 +177,7 @@ func (client *VirtualMachinesClient) createCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -197,32 +190,34 @@ func (client *VirtualMachinesClient) createCreateRequest(ctx context.Context, re // BeginDelete - Implements virtual machine DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the virtual machine resource. -// options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the virtual machine resource. +// - options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete +// method. func (client *VirtualMachinesClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachinesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements virtual machine DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -247,7 +242,7 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -266,16 +261,17 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re // Get - Implements virtual machine GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the virtual machine resource. -// options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the virtual machine resource. +// - options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (VirtualMachinesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return VirtualMachinesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientGetResponse{}, err } @@ -300,7 +296,7 @@ func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -322,35 +318,37 @@ func (client *VirtualMachinesClient) getHandleResponse(resp *http.Response) (Vir // BeginInstallPatches - The operation to install patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The name of the resource group. -// name - The name of the vSphere VMware machine. -// installPatchesInput - Input for InstallPatches as directly received by the API -// options - VirtualMachinesClientBeginInstallPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginInstallPatches -// method. +// - resourceGroupName - The name of the resource group. +// - name - The name of the vSphere VMware machine. +// - installPatchesInput - Input for InstallPatches as directly received by the API +// - options - VirtualMachinesClientBeginInstallPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginInstallPatches +// method. func (client *VirtualMachinesClient) BeginInstallPatches(ctx context.Context, resourceGroupName string, name string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*runtime.Poller[VirtualMachinesClientInstallPatchesResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.installPatches(ctx, resourceGroupName, name, installPatchesInput, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachinesClientInstallPatchesResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientInstallPatchesResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientInstallPatchesResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientInstallPatchesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // InstallPatches - The operation to install patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) installPatches(ctx context.Context, resourceGroupName string, name string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*http.Response, error) { req, err := client.installPatchesCreateRequest(ctx, resourceGroupName, name, installPatchesInput, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -375,7 +373,7 @@ func (client *VirtualMachinesClient) installPatchesCreateRequest(ctx context.Con return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -387,9 +385,10 @@ func (client *VirtualMachinesClient) installPatchesCreateRequest(ctx context.Con } // NewListPager - List of virtualMachines in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.List method. +// - options - VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.NewListPager +// method. func (client *VirtualMachinesClient) NewListPager(options *VirtualMachinesClientListOptions) *runtime.Pager[VirtualMachinesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListResponse]{ More: func(page VirtualMachinesClientListResponse) bool { @@ -406,7 +405,7 @@ func (client *VirtualMachinesClient) NewListPager(options *VirtualMachinesClient if err != nil { return VirtualMachinesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientListResponse{}, err } @@ -425,7 +424,7 @@ func (client *VirtualMachinesClient) listCreateRequest(ctx context.Context, opti return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -446,11 +445,11 @@ func (client *VirtualMachinesClient) listHandleResponse(resp *http.Response) (Vi } // NewListByResourceGroupPager - List of virtualMachines in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager +// method. func (client *VirtualMachinesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachinesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListByResourceGroupResponse]{ More: func(page VirtualMachinesClientListByResourceGroupResponse) bool { @@ -467,7 +466,7 @@ func (client *VirtualMachinesClient) NewListByResourceGroupPager(resourceGroupNa if err != nil { return VirtualMachinesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientListByResourceGroupResponse{}, err } @@ -490,7 +489,7 @@ func (client *VirtualMachinesClient) listByResourceGroupCreateRequest(ctx contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -512,32 +511,34 @@ func (client *VirtualMachinesClient) listByResourceGroupHandleResponse(resp *htt // BeginRestart - Restart virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the virtual machine resource. -// options - VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the virtual machine resource. +// - options - VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart +// method. func (client *VirtualMachinesClient) BeginRestart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*runtime.Poller[VirtualMachinesClientRestartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.restart(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientRestartResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientRestartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientRestartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientRestartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Restart - Restart virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) restart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*http.Response, error) { req, err := client.restartCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -562,7 +563,7 @@ func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, r return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -575,32 +576,34 @@ func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, r // BeginStart - Start virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the virtual machine resource. -// options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the virtual machine resource. +// - options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart +// method. func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*runtime.Poller[VirtualMachinesClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - Start virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -625,7 +628,7 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -638,32 +641,34 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res // BeginStop - Stop virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the virtual machine resource. -// options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the virtual machine resource. +// - options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop +// method. func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*runtime.Poller[VirtualMachinesClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stop virtual machine. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -688,7 +693,7 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -704,33 +709,35 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso // BeginUpdate - API to update certain properties of the virtual machine resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineName - Name of the virtual machine resource. -// body - Resource properties to update. -// options - VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - Name of the virtual machine resource. +// - body - Resource properties to update. +// - options - VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate +// method. func (client *VirtualMachinesClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachinesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, virtualMachineName, body, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - API to update certain properties of the virtual machine resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachinesClient) update(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -755,7 +762,7 @@ func (client *VirtualMachinesClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go index 24bc2a6868d0..80a297d6b962 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -19,18 +28,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/VirtualMachineAssessPatches.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/VirtualMachineAssessPatches.json func ExampleVirtualMachinesClient_BeginAssessPatches() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("{subscription-id}", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginAssessPatches(ctx, "myResourceGroupName", "myMachineName", nil) + poller, err := clientFactory.NewVirtualMachinesClient().BeginAssessPatches(ctx, "myResourceGroupName", "myMachineName", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -38,22 +47,42 @@ func ExampleVirtualMachinesClient_BeginAssessPatches() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachineAssessPatchesResult = armconnectedvmware.VirtualMachineAssessPatchesResult{ + // AssessmentActivityID: to.Ptr("68f8b292-dfc2-4646-9781-33cc88631968"), + // AvailablePatchCountByClassification: &armconnectedvmware.AvailablePatchCountByClassification{ + // Critical: to.Ptr[int32](0), + // Definition: to.Ptr[int32](0), + // FeaturePack: to.Ptr[int32](0), + // Security: to.Ptr[int32](0), + // ServicePack: to.Ptr[int32](0), + // Tools: to.Ptr[int32](0), + // UpdateRollup: to.Ptr[int32](1), + // Updates: to.Ptr[int32](1), + // }, + // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-15T02:16:06.9740000Z"); return t}()), + // OSType: to.Ptr(armconnectedvmware.OsTypeUMWindows), + // RebootPending: to.Ptr(true), + // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-15T02:15:20.9340000Z"); return t}()), + // StartedBy: to.Ptr(armconnectedvmware.PatchOperationStartedByUser), + // Status: to.Ptr(armconnectedvmware.PatchOperationStatusSucceeded), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/VirtualMachineInstallPatches.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/VirtualMachineInstallPatches.json func ExampleVirtualMachinesClient_BeginInstallPatches() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("{subscription-id}", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginInstallPatches(ctx, "myResourceGroupName", "myMachineName", armconnectedvmware.VirtualMachineInstallPatchesParameters{ + poller, err := clientFactory.NewVirtualMachinesClient().BeginInstallPatches(ctx, "myResourceGroupName", "myMachineName", armconnectedvmware.VirtualMachineInstallPatchesParameters{ MaximumDuration: to.Ptr("PT3H"), RebootSetting: to.Ptr(armconnectedvmware.VMGuestPatchRebootSettingIfRequired), WindowsParameters: &armconnectedvmware.WindowsParameters{ @@ -70,22 +99,38 @@ func ExampleVirtualMachinesClient_BeginInstallPatches() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachineInstallPatchesResult = armconnectedvmware.VirtualMachineInstallPatchesResult{ + // ExcludedPatchCount: to.Ptr[int32](0), + // FailedPatchCount: to.Ptr[int32](0), + // InstallationActivityID: to.Ptr("68f8b292-dfc2-4646-9781-33cc88631968"), + // InstalledPatchCount: to.Ptr[int32](3), + // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-15T02:16:06.9740000Z"); return t}()), + // MaintenanceWindowExceeded: to.Ptr(false), + // NotSelectedPatchCount: to.Ptr[int32](0), + // OSType: to.Ptr(armconnectedvmware.OsTypeUMWindows), + // PendingPatchCount: to.Ptr[int32](2), + // RebootStatus: to.Ptr(armconnectedvmware.VMGuestPatchRebootStatusCompleted), + // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-15T02:15:06.9740000Z"); return t}()), + // StartedBy: to.Ptr(armconnectedvmware.PatchOperationStartedByUser), + // Status: to.Ptr(armconnectedvmware.PatchOperationStatusSucceeded), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualMachine.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualMachine.json func ExampleVirtualMachinesClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "DemoVM", armconnectedvmware.VirtualMachine{ + poller, err := clientFactory.NewVirtualMachinesClient().BeginCreate(ctx, "testrg", "DemoVM", armconnectedvmware.VirtualMachine{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -108,41 +153,93 @@ func ExampleVirtualMachinesClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachine = armconnectedvmware.VirtualMachine{ + // Name: to.Ptr("DemoVM"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineProperties{ + // HardwareProfile: &armconnectedvmware.HardwareProfile{ + // MemorySizeMB: to.Ptr[int32](4196), + // NumCPUs: to.Ptr[int32](4), + // }, + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // OSProfile: &armconnectedvmware.OsProfile{ + // ComputerName: to.Ptr("DemoVM"), + // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualMachine.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualMachine.json func ExampleVirtualMachinesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "DemoVM", nil) + res, err := clientFactory.NewVirtualMachinesClient().Get(ctx, "testrg", "DemoVM", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachine = armconnectedvmware.VirtualMachine{ + // Name: to.Ptr("DemoVM"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineProperties{ + // HardwareProfile: &armconnectedvmware.HardwareProfile{ + // MemorySizeMB: to.Ptr[int32](4196), + // NumCPUs: to.Ptr[int32](4), + // }, + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // OSProfile: &armconnectedvmware.OsProfile{ + // ComputerName: to.Ptr("DemoVM"), + // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualMachine.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualMachine.json func ExampleVirtualMachinesClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "testrg", "DemoVM", armconnectedvmware.VirtualMachineUpdate{ + poller, err := clientFactory.NewVirtualMachinesClient().BeginUpdate(ctx, "testrg", "DemoVM", armconnectedvmware.VirtualMachineUpdate{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -155,22 +252,52 @@ func ExampleVirtualMachinesClient_BeginUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachine = armconnectedvmware.VirtualMachine{ + // Name: to.Ptr("DemoVM"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineProperties{ + // HardwareProfile: &armconnectedvmware.HardwareProfile{ + // MemorySizeMB: to.Ptr[int32](4196), + // NumCPUs: to.Ptr[int32](4), + // }, + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // OSProfile: &armconnectedvmware.OsProfile{ + // ComputerName: to.Ptr("DemoVM"), + // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualMachine.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualMachine.json func ExampleVirtualMachinesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "DemoVM", &armconnectedvmware.VirtualMachinesClientBeginDeleteOptions{Force: nil, + poller, err := clientFactory.NewVirtualMachinesClient().BeginDelete(ctx, "testrg", "DemoVM", &armconnectedvmware.VirtualMachinesClientBeginDeleteOptions{Force: nil, Retain: nil, }) if err != nil { @@ -182,18 +309,18 @@ func ExampleVirtualMachinesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/StopVirtualMachine.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/StopVirtualMachine.json func ExampleVirtualMachinesClient_BeginStop() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStop(ctx, "testrg", "DemoVM", &armconnectedvmware.VirtualMachinesClientBeginStopOptions{Body: &armconnectedvmware.StopVirtualMachineOptions{ + poller, err := clientFactory.NewVirtualMachinesClient().BeginStop(ctx, "testrg", "DemoVM", &armconnectedvmware.VirtualMachinesClientBeginStopOptions{Body: &armconnectedvmware.StopVirtualMachineOptions{ SkipShutdown: to.Ptr(true), }, }) @@ -206,18 +333,18 @@ func ExampleVirtualMachinesClient_BeginStop() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/StartVirtualMachine.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/StartVirtualMachine.json func ExampleVirtualMachinesClient_BeginStart() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStart(ctx, "testrg", "DemoVM", nil) + poller, err := clientFactory.NewVirtualMachinesClient().BeginStart(ctx, "testrg", "DemoVM", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -227,18 +354,18 @@ func ExampleVirtualMachinesClient_BeginStart() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/RestartVirtualMachine.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/RestartVirtualMachine.json func ExampleVirtualMachinesClient_BeginRestart() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginRestart(ctx, "testrg", "DemoVM", nil) + poller, err := clientFactory.NewVirtualMachinesClient().BeginRestart(ctx, "testrg", "DemoVM", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -248,50 +375,108 @@ func ExampleVirtualMachinesClient_BeginRestart() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachines.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachines.json func ExampleVirtualMachinesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewVirtualMachinesClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VirtualMachinesList = armconnectedvmware.VirtualMachinesList{ + // Value: []*armconnectedvmware.VirtualMachine{ + // { + // Name: to.Ptr("DemoVM"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineProperties{ + // HardwareProfile: &armconnectedvmware.HardwareProfile{ + // MemorySizeMB: to.Ptr[int32](4196), + // NumCPUs: to.Ptr[int32](4), + // }, + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // OSProfile: &armconnectedvmware.OsProfile{ + // ComputerName: to.Ptr("DemoVM"), + // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachinesByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachinesByResourceGroup.json func ExampleVirtualMachinesClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachinesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewVirtualMachinesClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VirtualMachinesList = armconnectedvmware.VirtualMachinesList{ + // Value: []*armconnectedvmware.VirtualMachine{ + // { + // Name: to.Ptr("DemoVM"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineProperties{ + // HardwareProfile: &armconnectedvmware.HardwareProfile{ + // MemorySizeMB: to.Ptr[int32](4196), + // NumCPUs: to.Ptr[int32](4), + // }, + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // OSProfile: &armconnectedvmware.OsProfile{ + // ComputerName: to.Ptr("DemoVM"), + // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), + // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go index 8e88177ae43b..68c3fff50fca 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,66 +33,59 @@ import ( // VirtualMachineTemplatesClient contains the methods for the VirtualMachineTemplates group. // Don't use this type directly, use NewVirtualMachineTemplatesClient() instead. type VirtualMachineTemplatesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualMachineTemplatesClient creates a new instance of VirtualMachineTemplatesClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualMachineTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachineTemplatesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VirtualMachineTemplatesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualMachineTemplatesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update virtual machine template. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineTemplateName - Name of the virtual machine template resource. -// body - Request payload. -// options - VirtualMachineTemplatesClientBeginCreateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreate -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineTemplateName - Name of the virtual machine template resource. +// - body - Request payload. +// - options - VirtualMachineTemplatesClientBeginCreateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreate +// method. func (client *VirtualMachineTemplatesClient) BeginCreate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOptions) (*runtime.Poller[VirtualMachineTemplatesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, virtualMachineTemplateName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachineTemplatesClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineTemplatesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineTemplatesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineTemplatesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update virtual machine template. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachineTemplatesClient) create(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -119,7 +110,7 @@ func (client *VirtualMachineTemplatesClient) createCreateRequest(ctx context.Con return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -132,32 +123,34 @@ func (client *VirtualMachineTemplatesClient) createCreateRequest(ctx context.Con // BeginDelete - Implements virtual machine template DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineTemplateName - Name of the virtual machine template resource. -// options - VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineTemplateName - Name of the virtual machine template resource. +// - options - VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete +// method. func (client *VirtualMachineTemplatesClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachineTemplatesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, virtualMachineTemplateName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachineTemplatesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachineTemplatesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineTemplatesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineTemplatesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements virtual machine template DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualMachineTemplatesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -182,7 +175,7 @@ func (client *VirtualMachineTemplatesClient) deleteCreateRequest(ctx context.Con return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *VirtualMachineTemplatesClient) deleteCreateRequest(ctx context.Con // Get - Implements virtual machine template GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineTemplateName - Name of the virtual machine template resource. -// options - VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineTemplateName - Name of the virtual machine template resource. +// - options - VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get +// method. func (client *VirtualMachineTemplatesClient) Get(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientGetOptions) (VirtualMachineTemplatesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, options) if err != nil { return VirtualMachineTemplatesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientGetResponse{}, err } @@ -233,7 +227,7 @@ func (client *VirtualMachineTemplatesClient) getCreateRequest(ctx context.Contex return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -254,10 +248,10 @@ func (client *VirtualMachineTemplatesClient) getHandleResponse(resp *http.Respon } // NewListPager - List of virtualMachineTemplates in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.List -// method. +// - options - VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListPager +// method. func (client *VirtualMachineTemplatesClient) NewListPager(options *VirtualMachineTemplatesClientListOptions) *runtime.Pager[VirtualMachineTemplatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachineTemplatesClientListResponse]{ More: func(page VirtualMachineTemplatesClientListResponse) bool { @@ -274,7 +268,7 @@ func (client *VirtualMachineTemplatesClient) NewListPager(options *VirtualMachin if err != nil { return VirtualMachineTemplatesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientListResponse{}, err } @@ -293,7 +287,7 @@ func (client *VirtualMachineTemplatesClient) listCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -314,11 +308,11 @@ func (client *VirtualMachineTemplatesClient) listHandleResponse(resp *http.Respo } // NewListByResourceGroupPager - List of virtualMachineTemplates in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListByResourceGroupPager +// method. func (client *VirtualMachineTemplatesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachineTemplatesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachineTemplatesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachineTemplatesClientListByResourceGroupResponse]{ More: func(page VirtualMachineTemplatesClientListByResourceGroupResponse) bool { @@ -335,7 +329,7 @@ func (client *VirtualMachineTemplatesClient) NewListByResourceGroupPager(resourc if err != nil { return VirtualMachineTemplatesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientListByResourceGroupResponse{}, err } @@ -358,7 +352,7 @@ func (client *VirtualMachineTemplatesClient) listByResourceGroupCreateRequest(ct return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -380,18 +374,19 @@ func (client *VirtualMachineTemplatesClient) listByResourceGroupHandleResponse(r // Update - API to update certain properties of the virtual machine template resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualMachineTemplateName - Name of the virtual machine template resource. -// body - Resource properties to update. -// options - VirtualMachineTemplatesClientUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.Update -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualMachineTemplateName - Name of the virtual machine template resource. +// - body - Resource properties to update. +// - options - VirtualMachineTemplatesClientUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.Update +// method. func (client *VirtualMachineTemplatesClient) Update(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientUpdateOptions) (VirtualMachineTemplatesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, body, options) if err != nil { return VirtualMachineTemplatesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientUpdateResponse{}, err } @@ -416,7 +411,7 @@ func (client *VirtualMachineTemplatesClient) updateCreateRequest(ctx context.Con return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go index 3c8f0f336ac9..a2eb361f92ce 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualMachineTemplate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualMachineTemplate.json func ExampleVirtualMachineTemplatesClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachineTemplatesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "WebFrontEndTemplate", armconnectedvmware.VirtualMachineTemplate{ + poller, err := clientFactory.NewVirtualMachineTemplatesClient().BeginCreate(ctx, "testrg", "WebFrontEndTemplate", armconnectedvmware.VirtualMachineTemplate{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -46,41 +55,73 @@ func ExampleVirtualMachineTemplatesClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachineTemplate = armconnectedvmware.VirtualMachineTemplate{ + // Name: to.Ptr("WebFrontEndTemplate"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualMachineTemplate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualMachineTemplate.json func ExampleVirtualMachineTemplatesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachineTemplatesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "WebFrontEndTemplate", nil) + res, err := clientFactory.NewVirtualMachineTemplatesClient().Get(ctx, "testrg", "WebFrontEndTemplate", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachineTemplate = armconnectedvmware.VirtualMachineTemplate{ + // Name: to.Ptr("WebFrontEndTemplate"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualMachineTemplate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualMachineTemplate.json func ExampleVirtualMachineTemplatesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachineTemplatesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "testrg", "WebFrontEndTemplate", armconnectedvmware.ResourcePatch{ + res, err := clientFactory.NewVirtualMachineTemplatesClient().Update(ctx, "testrg", "WebFrontEndTemplate", armconnectedvmware.ResourcePatch{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -89,22 +130,42 @@ func ExampleVirtualMachineTemplatesClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualMachineTemplate = armconnectedvmware.VirtualMachineTemplate{ + // Name: to.Ptr("WebFrontEndTemplate"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualMachineTemplate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualMachineTemplate.json func ExampleVirtualMachineTemplatesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachineTemplatesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "WebFrontEndTemplate", &armconnectedvmware.VirtualMachineTemplatesClientBeginDeleteOptions{Force: nil}) + poller, err := clientFactory.NewVirtualMachineTemplatesClient().BeginDelete(ctx, "testrg", "WebFrontEndTemplate", &armconnectedvmware.VirtualMachineTemplatesClientBeginDeleteOptions{Force: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -114,50 +175,88 @@ func ExampleVirtualMachineTemplatesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachineTemplates.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachineTemplates.json func ExampleVirtualMachineTemplatesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachineTemplatesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewVirtualMachineTemplatesClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VirtualMachineTemplatesList = armconnectedvmware.VirtualMachineTemplatesList{ + // Value: []*armconnectedvmware.VirtualMachineTemplate{ + // { + // Name: to.Ptr("WebFrontEndTemplate"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachineTemplatesByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachineTemplatesByResourceGroup.json func ExampleVirtualMachineTemplatesClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualMachineTemplatesClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewVirtualMachineTemplatesClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VirtualMachineTemplatesList = armconnectedvmware.VirtualMachineTemplatesList{ + // Value: []*armconnectedvmware.VirtualMachineTemplate{ + // { + // Name: to.Ptr("WebFrontEndTemplate"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go index d59affc621e5..2a5a458829db 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -35,66 +33,59 @@ import ( // VirtualNetworksClient contains the methods for the VirtualNetworks group. // Don't use this type directly, use NewVirtualNetworksClient() instead. type VirtualNetworksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualNetworksClient creates a new instance of VirtualNetworksClient with the specified values. -// subscriptionID - The Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VirtualNetworksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualNetworksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create Or Update virtual network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualNetworkName - Name of the virtual network resource. -// body - Request payload. -// options - VirtualNetworksClientBeginCreateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreate -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualNetworkName - Name of the virtual network resource. +// - body - Request payload. +// - options - VirtualNetworksClientBeginCreateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreate +// method. func (client *VirtualNetworksClient) BeginCreate(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOptions) (*runtime.Poller[VirtualNetworksClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, virtualNetworkName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualNetworksClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualNetworksClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworksClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworksClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create Or Update virtual network. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualNetworksClient) create(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, virtualNetworkName, body, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -119,7 +110,7 @@ func (client *VirtualNetworksClient) createCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -132,32 +123,34 @@ func (client *VirtualNetworksClient) createCreateRequest(ctx context.Context, re // BeginDelete - Implements virtual network DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualNetworkName - Name of the virtual network resource. -// options - VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete -// method. +// - resourceGroupName - The Resource Group Name. +// - virtualNetworkName - Name of the virtual network resource. +// - options - VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete +// method. func (client *VirtualNetworksClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientBeginDeleteOptions) (*runtime.Poller[VirtualNetworksClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, virtualNetworkName, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworksClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualNetworksClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualNetworksClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualNetworksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Implements virtual network DELETE method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview func (client *VirtualNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualNetworkName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -182,7 +175,7 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,16 +191,17 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re // Get - Implements virtual network GET method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualNetworkName - Name of the virtual network resource. -// options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. +// - resourceGroupName - The Resource Group Name. +// - virtualNetworkName - Name of the virtual network resource. +// - options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. func (client *VirtualNetworksClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientGetOptions) (VirtualNetworksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, virtualNetworkName, options) if err != nil { return VirtualNetworksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientGetResponse{}, err } @@ -232,7 +226,7 @@ func (client *VirtualNetworksClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter virtualNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,9 +247,10 @@ func (client *VirtualNetworksClient) getHandleResponse(resp *http.Response) (Vir } // NewListPager - List of virtualNetworks in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// options - VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.List method. +// - options - VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager +// method. func (client *VirtualNetworksClient) NewListPager(options *VirtualNetworksClientListOptions) *runtime.Pager[VirtualNetworksClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualNetworksClientListResponse]{ More: func(page VirtualNetworksClientListResponse) bool { @@ -272,7 +267,7 @@ func (client *VirtualNetworksClient) NewListPager(options *VirtualNetworksClient if err != nil { return VirtualNetworksClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientListResponse{}, err } @@ -291,7 +286,7 @@ func (client *VirtualNetworksClient) listCreateRequest(ctx context.Context, opti return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -312,11 +307,11 @@ func (client *VirtualNetworksClient) listHandleResponse(resp *http.Response) (Vi } // NewListByResourceGroupPager - List of virtualNetworks in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// options - VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.ListByResourceGroup -// method. +// - resourceGroupName - The Resource Group Name. +// - options - VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.NewListByResourceGroupPager +// method. func (client *VirtualNetworksClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualNetworksClientListByResourceGroupOptions) *runtime.Pager[VirtualNetworksClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualNetworksClientListByResourceGroupResponse]{ More: func(page VirtualNetworksClientListByResourceGroupResponse) bool { @@ -333,7 +328,7 @@ func (client *VirtualNetworksClient) NewListByResourceGroupPager(resourceGroupNa if err != nil { return VirtualNetworksClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientListByResourceGroupResponse{}, err } @@ -356,7 +351,7 @@ func (client *VirtualNetworksClient) listByResourceGroupCreateRequest(ctx contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -378,17 +373,18 @@ func (client *VirtualNetworksClient) listByResourceGroupHandleResponse(resp *htt // Update - API to update certain properties of the virtual network resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-10-preview -// resourceGroupName - The Resource Group Name. -// virtualNetworkName - Name of the virtual network resource. -// body - Resource properties to update. -// options - VirtualNetworksClientUpdateOptions contains the optional parameters for the VirtualNetworksClient.Update method. +// - resourceGroupName - The Resource Group Name. +// - virtualNetworkName - Name of the virtual network resource. +// - body - Resource properties to update. +// - options - VirtualNetworksClientUpdateOptions contains the optional parameters for the VirtualNetworksClient.Update method. func (client *VirtualNetworksClient) Update(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientUpdateOptions) (VirtualNetworksClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualNetworkName, body, options) if err != nil { return VirtualNetworksClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientUpdateResponse{}, err } @@ -413,7 +409,7 @@ func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go index 756e87a3d6c9..0b86165719d3 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go @@ -2,9 +2,18 @@ // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. +// DO NOT EDIT. package armconnectedvmware_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualNetwork.json func ExampleVirtualNetworksClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualNetworksClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "testrg", "ProdNetwork", armconnectedvmware.VirtualNetwork{ + poller, err := clientFactory.NewVirtualNetworksClient().BeginCreate(ctx, "testrg", "ProdNetwork", armconnectedvmware.VirtualNetwork{ ExtendedLocation: &armconnectedvmware.ExtendedLocation{ Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), Type: to.Ptr("customLocation"), @@ -46,41 +55,73 @@ func ExampleVirtualNetworksClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualNetwork = armconnectedvmware.VirtualNetwork{ + // Name: to.Ptr("ProdNetwork"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualNetworkProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualNetwork.json func ExampleVirtualNetworksClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualNetworksClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "testrg", "ProdNetwork", nil) + res, err := clientFactory.NewVirtualNetworksClient().Get(ctx, "testrg", "ProdNetwork", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualNetwork = armconnectedvmware.VirtualNetwork{ + // Name: to.Ptr("ProdNetwork"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualNetworkProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualNetwork.json func ExampleVirtualNetworksClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualNetworksClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "testrg", "ProdNetwork", armconnectedvmware.ResourcePatch{ + res, err := clientFactory.NewVirtualNetworksClient().Update(ctx, "testrg", "ProdNetwork", armconnectedvmware.ResourcePatch{ Tags: map[string]*string{ "tag1": to.Ptr("value1"), "tag2": to.Ptr("value2"), @@ -89,22 +130,42 @@ func ExampleVirtualNetworksClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.VirtualNetwork = armconnectedvmware.VirtualNetwork{ + // Name: to.Ptr("ProdNetwork"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualNetworkProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualNetwork.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualNetwork.json func ExampleVirtualNetworksClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualNetworksClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "testrg", "ProdNetwork", &armconnectedvmware.VirtualNetworksClientBeginDeleteOptions{Force: nil}) + poller, err := clientFactory.NewVirtualNetworksClient().BeginDelete(ctx, "testrg", "ProdNetwork", &armconnectedvmware.VirtualNetworksClientBeginDeleteOptions{Force: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -114,50 +175,88 @@ func ExampleVirtualNetworksClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualNetworks.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualNetworks.json func ExampleVirtualNetworksClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualNetworksClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewVirtualNetworksClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VirtualNetworksList = armconnectedvmware.VirtualNetworksList{ + // Value: []*armconnectedvmware.VirtualNetwork{ + // { + // Name: to.Ptr("ProdNetwork"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualNetworkProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualNetworksByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualNetworksByResourceGroup.json func ExampleVirtualNetworksClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armconnectedvmware.NewVirtualNetworksClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testrg", nil) + pager := clientFactory.NewVirtualNetworksClient().NewListByResourceGroupPager("testrg", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. _ = v } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.VirtualNetworksList = armconnectedvmware.VirtualNetworksList{ + // Value: []*armconnectedvmware.VirtualNetwork{ + // { + // Name: to.Ptr("ProdNetwork"), + // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), + // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ + // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), + // Type: to.Ptr("customLocation"), + // }, + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), + // Location: to.Ptr("East US"), + // Properties: &armconnectedvmware.VirtualNetworkProperties{ + // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + // ProvisioningState: to.Ptr("Succeeded"), + // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), + // }, + // }}, + // } } }