From 66a25c3303d39559d70b6016d6976f452a4680e8 Mon Sep 17 00:00:00 2001 From: mcardosos Date: Fri, 28 Apr 2017 16:13:01 -0700 Subject: [PATCH 1/6] Gen everything --- Gododir/gen.go | 296 +- arm/advisor/client.go | 53 + arm/advisor/models.go | 188 ++ arm/advisor/operations.go | 122 + arm/advisor/recommendations.go | 338 +++ arm/advisor/suppressions.go | 345 +++ arm/advisor/version.go | 29 + arm/analysisservices/models.go | 8 + arm/analysisservices/servers.go | 261 +- arm/analysisservices/version.go | 4 +- arm/apimanagement/apiexport.go | 122 + arm/apimanagement/apioperations.go | 100 +- arm/apimanagement/apioperationspolicy.go | 312 ++ arm/apimanagement/apipolicy.go | 289 ++ arm/apimanagement/apiproducts.go | 52 +- arm/apimanagement/apis.go | 134 +- arm/apimanagement/authorizationservers.go | 54 +- arm/apimanagement/backends.go | 79 +- arm/apimanagement/certificates.go | 58 +- arm/apimanagement/client.go | 5 +- arm/apimanagement/groups.go | 44 +- arm/apimanagement/groupusers.go | 248 +- arm/apimanagement/identityproviders.go | 44 +- arm/apimanagement/loggers.go | 81 +- arm/apimanagement/models.go | 518 +++- arm/apimanagement/networkstatus.go | 119 + arm/apimanagement/openidconnectproviders.go | 60 +- arm/apimanagement/operations.go | 123 + arm/apimanagement/policysnippets.go | 18 +- arm/apimanagement/productapis.go | 248 +- arm/apimanagement/productgroups.go | 234 +- arm/apimanagement/productpolicy.go | 290 ++ arm/apimanagement/products.go | 44 +- arm/apimanagement/productsubscriptions.go | 52 +- arm/apimanagement/properties.go | 163 + arm/apimanagement/property.go | 170 +- arm/apimanagement/quotabycounterkeys.go | 20 +- arm/apimanagement/quotabyperiodkeys.go | 20 +- arm/apimanagement/regions.go | 12 +- arm/apimanagement/reports.go | 20 +- arm/apimanagement/services.go | 1278 ++++++++ arm/apimanagement/subscriptions.go | 163 +- arm/apimanagement/tenantaccess.go | 36 +- arm/apimanagement/tenantaccessgit.go | 28 +- arm/apimanagement/tenantconfiguration.go | 187 +- .../tenantconfigurationsyncstate.go | 13 +- arm/apimanagement/tenantpolicy.go | 272 ++ arm/apimanagement/usergroups.go | 52 +- arm/apimanagement/useridentities.go | 40 +- arm/apimanagement/users.go | 52 +- arm/apimanagement/usersubscriptions.go | 52 +- arm/apimanagement/version.go | 4 +- arm/appinsights/client.go | 53 + arm/appinsights/components.go | 497 ++++ arm/appinsights/models.go | 226 ++ arm/appinsights/operations.go | 123 + arm/appinsights/version.go | 29 + arm/appinsights/webtests.go | 499 ++++ arm/authorization/classicadministrators.go | 6 +- arm/authorization/permissions.go | 12 +- .../provideroperationsmetadata.go | 12 +- arm/authorization/roleassignments.go | 62 +- arm/authorization/roledefinitions.go | 30 +- arm/authorization/version.go | 4 +- arm/automation/account.go | 514 ++++ arm/automation/activity.go | 216 ++ .../agentregistrationinformation.go | 191 ++ arm/automation/certificate.go | 441 +++ arm/automation/client.go | 52 + arm/automation/connection.go | 442 +++ arm/automation/connectiontype.go | 366 +++ arm/automation/credential.go | 443 +++ arm/automation/dsccompilationjob.go | 373 +++ arm/automation/dscconfiguration.go | 444 +++ arm/automation/dscnode.go | 362 +++ arm/automation/dscnodeconfiguration.go | 377 +++ arm/automation/fields.go | 117 + arm/automation/hybridrunbookworkergroup.go | 363 +++ arm/automation/job.go | 654 ++++ arm/automation/jobschedule.go | 365 +++ arm/automation/jobstream.go | 218 ++ arm/automation/models.go | 1926 ++++++++++++ arm/automation/module.go | 443 +++ arm/automation/nodereports.go | 292 ++ arm/automation/objectdatatypes.go | 194 ++ arm/automation/operations.go | 98 + arm/automation/runbook.go | 523 ++++ arm/automation/runbookdraft.go | 447 +++ arm/automation/schedule.go | 439 +++ arm/automation/statistics.go | 117 + arm/automation/testjobs.go | 410 +++ arm/automation/testjobstreams.go | 221 ++ arm/automation/usages.go | 113 + arm/automation/variable.go | 438 +++ arm/automation/version.go | 29 + arm/automation/webhook.go | 512 ++++ arm/batch/account.go | 163 +- arm/batch/application.go | 30 +- arm/batch/applicationpackage.go | 24 +- arm/batch/location.go | 6 +- arm/batch/version.go | 4 +- arm/billing/client.go | 7 +- arm/billing/invoices.go | 31 +- arm/billing/models.go | 49 +- arm/billing/operations.go | 9 +- arm/billing/periods.go | 221 ++ arm/billing/version.go | 35 +- arm/cdn/client.go | 18 +- arm/cdn/customdomains.go | 150 +- arm/cdn/edgenodes.go | 6 +- arm/cdn/endpoints.go | 450 ++- arm/cdn/origins.go | 71 +- arm/cdn/profiles.go | 214 +- arm/cdn/version.go | 4 +- arm/cognitiveservices/accounts.go | 54 +- arm/cognitiveservices/version.go | 4 +- arm/commerce/client.go | 8 +- arm/commerce/models.go | 27 +- arm/commerce/ratecard.go | 29 +- arm/commerce/usageaggregates.go | 39 +- arm/commerce/version.go | 35 +- arm/compute/availabilitysets.go | 30 +- arm/compute/images.go | 135 +- arm/compute/usage.go | 6 +- arm/compute/version.go | 4 +- arm/compute/virtualmachineextensionimages.go | 18 +- arm/compute/virtualmachineextensions.go | 114 +- arm/compute/virtualmachineimages.go | 30 +- arm/compute/virtualmachines.go | 534 ++-- arm/compute/virtualmachinescalesets.go | 588 ++-- arm/compute/virtualmachinescalesetvms.go | 396 ++- arm/compute/virtualmachinesizes.go | 6 +- arm/consumption/client.go | 56 + arm/consumption/models.go | 141 + arm/consumption/operations.go | 125 + arm/consumption/usagedetails.go | 170 ++ arm/consumption/version.go | 29 + arm/containerregistry/client.go | 2 +- arm/containerregistry/models.go | 372 ++- arm/containerregistry/operations.go | 124 + arm/containerregistry/registries.go | 468 +-- arm/containerregistry/replications.go | 421 +++ arm/containerregistry/version.go | 4 +- arm/containerregistry/webhooks.go | 775 +++++ arm/containerservice/client.go | 2 +- arm/containerservice/containerservices.go | 140 +- arm/containerservice/version.go | 4 +- .../authorizationpolicies.go | 45 +- arm/customer-insights/client.go | 5 - arm/customer-insights/connectormappings.go | 36 +- arm/customer-insights/connectors.go | 132 +- arm/customer-insights/hubs.go | 97 +- arm/customer-insights/images.go | 18 +- arm/customer-insights/interactions.go | 148 +- arm/customer-insights/kpi.go | 141 +- arm/customer-insights/links.go | 89 +- arm/customer-insights/models.go | 181 +- arm/customer-insights/profiles.go | 202 +- arm/customer-insights/relationshiplinks.go | 132 +- arm/customer-insights/relationships.go | 132 +- arm/customer-insights/roleassignments.go | 89 +- arm/customer-insights/roles.go | 9 +- arm/customer-insights/version.go | 35 +- arm/customer-insights/views.go | 36 +- arm/customer-insights/widgettypes.go | 18 +- .../account/accountgroup.go | 184 +- .../account/datalakestoreaccounts.go | 24 +- .../account/firewallrules.go | 30 +- .../account/storageaccounts.go | 48 +- arm/datalake-analytics/account/version.go | 4 +- arm/datalake-store/account/accountgroup.go | 190 +- arm/datalake-store/account/firewallrules.go | 30 +- .../account/trustedidproviders.go | 30 +- arm/datalake-store/account/version.go | 4 +- arm/devtestlabs/armtemplates.go | 221 ++ .../{artifactoperations.go => artifacts.go} | 135 +- ...sourceoperations.go => artifactsources.go} | 217 +- arm/devtestlabs/client.go | 13 +- arm/devtestlabs/costoperations.go | 106 - arm/devtestlabs/costs.go | 187 ++ arm/devtestlabs/customimageoperations.go | 343 --- arm/devtestlabs/customimages.go | 395 +++ arm/devtestlabs/disks.go | 574 ++++ arm/devtestlabs/environments.go | 403 +++ arm/devtestlabs/formulaoperations.go | 338 --- arm/devtestlabs/formulas.go | 393 +++ ...eryimageoperations.go => galleryimages.go} | 65 +- arm/devtestlabs/globalschedules.go | 691 +++++ arm/devtestlabs/laboperations.go | 719 ----- arm/devtestlabs/labs.go | 977 ++++++ arm/devtestlabs/models.go | 1439 +++++++-- arm/devtestlabs/notificationchannels.go | 501 ++++ .../{policyoperations.go => policies.go} | 213 +- .../{policyset.go => policysets.go} | 42 +- arm/devtestlabs/scheduleoperations.go | 467 --- arm/devtestlabs/schedules.go | 601 ++++ arm/devtestlabs/secrets.go | 366 +++ arm/devtestlabs/servicerunners.go | 346 +++ arm/devtestlabs/users.go | 439 +++ arm/devtestlabs/version.go | 35 +- arm/devtestlabs/virtualmachine.go | 615 ---- arm/devtestlabs/virtualmachines.go | 1045 +++++++ arm/devtestlabs/virtualmachineschedules.go | 523 ++++ arm/devtestlabs/virtualnetworkoperations.go | 409 --- arm/devtestlabs/virtualnetworks.go | 457 +++ arm/disk/disks.go | 306 +- arm/disk/snapshots.go | 306 +- arm/disk/version.go | 4 +- arm/dns/recordsets.go | 36 +- arm/dns/version.go | 4 +- arm/dns/zones.go | 78 +- arm/documentdb/databaseaccounts.go | 342 ++- arm/documentdb/version.go | 4 +- arm/eventhub/consumergroups.go | 108 +- arm/eventhub/eventhubs.go | 258 +- arm/eventhub/models.go | 203 +- arm/eventhub/namespaces.go | 470 +-- arm/eventhub/operations.go | 8 +- arm/eventhub/version.go | 4 +- arm/graphrbac/applications.go | 93 +- arm/graphrbac/client.go | 21 +- arm/graphrbac/groups.go | 102 +- arm/graphrbac/models.go | 8 + arm/graphrbac/objects.go | 150 +- arm/graphrbac/serviceprincipals.go | 84 +- arm/graphrbac/users.go | 66 +- arm/graphrbac/version.go | 35 +- arm/hdinsight/applications.go | 352 +++ arm/hdinsight/client.go | 52 + arm/hdinsight/clusters.go | 785 +++++ arm/hdinsight/configurations.go | 195 ++ arm/hdinsight/extension.go | 243 ++ arm/hdinsight/location.go | 105 + arm/hdinsight/models.go | 602 ++++ arm/hdinsight/operations.go | 122 + arm/hdinsight/scriptactions.go | 198 ++ arm/hdinsight/scriptexecutionhistory.go | 265 ++ arm/hdinsight/version.go | 29 + arm/insights/alertruleincidents.go | 176 ++ arm/insights/alertrules.go | 321 ++ arm/insights/autoscalesettings.go | 347 +++ arm/insights/client.go | 52 + arm/insights/logprofiles.go | 309 ++ arm/insights/models.go | 511 ++++ arm/insights/servicediagnosticsettings.go | 173 ++ arm/insights/version.go | 29 + arm/intune/android.go | 99 +- arm/intune/client.go | 110 +- arm/intune/ios.go | 99 +- arm/intune/version.go | 35 +- arm/iothub/resource.go | 219 +- arm/iothub/version.go | 4 +- arm/keyvault/vaults.go | 30 +- arm/keyvault/version.go | 4 +- arm/logic/agreements.go | 24 +- arm/logic/certificates.go | 24 +- arm/logic/client.go | 6 +- arm/logic/integrationaccounts.go | 42 +- arm/logic/maps.go | 24 +- arm/logic/models.go | 60 +- arm/logic/partners.go | 24 +- arm/logic/schemas.go | 24 +- arm/logic/sessions.go | 24 +- arm/logic/version.go | 4 +- arm/logic/workflowrunactions.go | 12 +- arm/logic/workflowruns.go | 18 +- arm/logic/workflows.go | 194 +- arm/logic/workflowtriggerhistories.go | 84 +- arm/logic/workflowtriggers.go | 24 +- arm/logic/workflowversions.go | 86 +- arm/machinelearning/commitmentplans/client.go | 5 - .../commitmentplans/commitmentassociations.go | 27 +- .../commitmentplans/commitmentplansgroup.go | 54 +- .../commitmentplans/usagehistory.go | 9 +- .../commitmentplans/version.go | 35 +- arm/machinelearning/webservices/client.go | 2 +- arm/machinelearning/webservices/models.go | 50 +- arm/machinelearning/webservices/version.go | 4 +- .../webservices/webservicesgroup.go | 400 ++- arm/mediaservices/mediaservice.go | 54 +- arm/mediaservices/version.go | 4 +- arm/mobileengagement/appcollections.go | 12 +- arm/mobileengagement/apps.go | 6 +- arm/mobileengagement/campaigns.go | 78 +- arm/mobileengagement/devices.go | 30 +- arm/mobileengagement/exporttasks.go | 72 +- arm/mobileengagement/importtasks.go | 18 +- arm/mobileengagement/supportedplatforms.go | 6 +- arm/mobileengagement/version.go | 4 +- arm/monitor/activitylogalerts.go | 452 +++ arm/monitor/alertruleincidents.go | 176 ++ arm/monitor/alertrules.go | 315 ++ arm/monitor/autoscalesettings.go | 341 +++ arm/monitor/client.go | 52 + arm/monitor/logprofiles.go | 311 ++ arm/monitor/models.go | 586 ++++ arm/monitor/servicediagnosticsettings.go | 242 ++ arm/monitor/version.go | 29 + arm/network/applicationgateways.go | 401 ++- arm/network/bgpservicecommunities.go | 127 + arm/network/client.go | 24 +- .../expressroutecircuitauthorizations.go | 166 +- arm/network/expressroutecircuitpeerings.go | 152 +- arm/network/expressroutecircuits.go | 387 ++- arm/network/expressrouteserviceproviders.go | 18 +- arm/network/interfaces.go | 332 ++- arm/network/loadbalancers.go | 170 +- arm/network/localnetworkgateways.go | 185 +- arm/network/models.go | 1028 ++++++- arm/network/packetcaptures.go | 526 ++++ arm/network/publicipaddresses.go | 169 +- arm/network/routefilterrules.go | 468 +++ arm/network/routefilters.go | 535 ++++ arm/network/routes.go | 148 +- arm/network/routetables.go | 158 +- arm/network/securitygroups.go | 150 +- arm/network/securityrules.go | 159 +- arm/network/subnets.go | 147 +- arm/network/usages.go | 17 +- arm/network/version.go | 35 +- .../virtualnetworkgatewayconnections.go | 346 ++- arm/network/virtualnetworkgateways.go | 481 ++- arm/network/virtualnetworkpeerings.go | 135 +- arm/network/virtualnetworks.go | 165 +- arm/network/watchers.go | 1131 +++++++ arm/notificationhubs/client.go | 2 +- arm/notificationhubs/models.go | 4 + arm/notificationhubs/namespaces.go | 147 +- arm/notificationhubs/notificationhubsgroup.go | 96 +- arm/notificationhubs/version.go | 4 +- arm/operationalinsights/client.go | 5 - arm/operationalinsights/datasources.go | 36 +- arm/operationalinsights/linkedservices.go | 36 +- arm/operationalinsights/version.go | 35 +- arm/operationalinsights/workspaces.go | 156 +- arm/powerbiembedded/client.go | 6 +- arm/powerbiembedded/version.go | 4 +- arm/powerbiembedded/workspacecollections.go | 103 +- arm/powerbiembedded/workspaces.go | 6 +- arm/recoveryservices/models.go | 149 +- arm/recoveryservices/operations.go | 131 + arm/recoveryservices/vaultextendedinfo.go | 250 ++ arm/recoveryservices/vaults.go | 151 +- arm/recoveryservices/version.go | 4 +- arm/recoveryservicesbackup/backupengines.go | 216 ++ arm/recoveryservicesbackup/backupjobs.go | 139 + .../backupoperationresults.go | 115 + .../backupoperationstatuses.go | 115 + arm/recoveryservicesbackup/backuppolicies.go | 138 + .../backupprotectableitems.go | 141 + .../backupprotecteditems.go | 141 + .../backupprotectioncontainers.go | 137 + .../backupresourcestorageconfigs.go | 174 ++ .../backupresourcevaultconfigs.go | 178 ++ arm/recoveryservicesbackup/backups.go | 117 + .../backupusagesummaries.go | 116 + arm/recoveryservicesbackup/client.go | 53 + .../exportjobsoperationresults.go | 114 + .../itemlevelrecoveryconnections.go | 198 ++ .../jobcancellations.go | 111 + arm/recoveryservicesbackup/jobdetails.go | 110 + .../joboperationresults.go | 113 + arm/recoveryservicesbackup/jobs.go | 111 + arm/recoveryservicesbackup/models.go | 2113 +++++++++++++ arm/recoveryservicesbackup/operations.go | 125 + .../protecteditemoperationresults.go | 117 + .../protecteditemoperationstatuses.go | 122 + arm/recoveryservicesbackup/protecteditems.go | 269 ++ .../protectioncontaineroperationresults.go | 116 + ...tectioncontainerrefreshoperationresults.go | 114 + .../protectioncontainers.go | 183 ++ .../protectionpolicies.go | 255 ++ .../protectionpolicyoperationresults.go | 115 + .../protectionpolicyoperationstatuses.go | 119 + arm/recoveryservicesbackup/recoverypoints.go | 219 ++ arm/recoveryservicesbackup/restores.go | 120 + arm/recoveryservicesbackup/securitypins.go | 108 + arm/recoveryservicesbackup/version.go | 29 + arm/redis/firewallrule.go | 18 +- arm/redis/firewallrules.go | 6 +- arm/redis/operations.go | 6 +- arm/redis/patchschedules.go | 18 +- arm/redis/redisgroup.go | 270 +- arm/redis/version.go | 4 +- arm/relay/client.go | 53 + arm/relay/hybridconnections.go | 943 ++++++ arm/relay/models.go | 330 +++ arm/relay/namespaces.go | 1167 ++++++++ arm/relay/operations.go | 123 + arm/relay/version.go | 29 + arm/relay/wcfrelays.go | 929 ++++++ arm/resourcehealth/availabilitystatuses.go | 425 +++ arm/resourcehealth/client.go | 55 + arm/resourcehealth/models.go | 163 + arm/resourcehealth/operations.go | 98 + arm/resourcehealth/version.go | 29 + arm/resources/features/client.go | 15 +- .../{features.go => featuresgroup.go} | 123 +- arm/resources/features/models.go | 30 +- arm/resources/features/version.go | 35 +- arm/resources/links/client.go | 5 - arm/resources/links/resourcelinks.go | 45 +- arm/resources/links/version.go | 35 +- arm/resources/locks/managementlocks.go | 90 +- arm/resources/locks/version.go | 4 +- arm/resources/policy/assignments.go | 54 +- arm/resources/policy/definitions.go | 24 +- arm/resources/policy/version.go | 4 +- .../resources/deploymentoperations.go | 12 +- arm/resources/resources/deployments.go | 157 +- arm/resources/resources/groups.go | 100 +- arm/resources/resources/providers.go | 24 +- arm/resources/resources/resourcesgroup.go | 321 +- arm/resources/resources/tags.go | 30 +- arm/resources/resources/version.go | 4 +- arm/resources/subscriptions/client.go | 19 +- arm/resources/subscriptions/models.go | 67 +- ...subscriptions.go => subscriptionsgroup.go} | 95 +- arm/resources/subscriptions/tenants.go | 15 +- arm/resources/subscriptions/version.go | 35 +- arm/scheduler/jobcollections.go | 177 +- arm/scheduler/jobs.go | 42 +- arm/scheduler/version.go | 4 +- arm/search/adminkeys.go | 12 +- arm/search/querykeys.go | 18 +- arm/search/services.go | 30 +- arm/search/version.go | 4 +- arm/servermanagement/gateway.go | 329 ++- arm/servermanagement/node.go | 150 +- arm/servermanagement/powershell.go | 270 +- arm/servermanagement/session.go | 71 +- arm/servermanagement/version.go | 4 +- arm/service-map/client.go | 5 - arm/service-map/clientgroups.go | 27 +- arm/service-map/machinegroups.go | 45 +- arm/service-map/machines.go | 63 +- arm/service-map/maps.go | 9 +- arm/service-map/models.go | 17 + arm/service-map/ports.go | 36 +- arm/service-map/processes.go | 36 +- arm/service-map/summaries.go | 9 +- arm/service-map/version.go | 35 +- arm/servicebus/models.go | 15 +- arm/servicebus/namespaces.go | 187 +- arm/servicebus/operations.go | 6 +- arm/servicebus/queues.go | 60 +- arm/servicebus/subscriptions.go | 24 +- arm/servicebus/topics.go | 60 +- arm/servicebus/version.go | 4 +- arm/servicefabric/client.go | 53 + arm/servicefabric/clusters.go | 572 ++++ arm/servicefabric/clusterversions.go | 134 + arm/servicefabric/models.go | 439 +++ arm/servicefabric/operations.go | 123 + arm/servicefabric/version.go | 29 + arm/sql/capabilities.go | 108 + arm/sql/client.go | 65 +- arm/sql/databases.go | 1291 +++++++- arm/sql/elasticpools.go | 103 +- arm/sql/firewallrules.go | 331 +++ arm/sql/models.go | 427 ++- arm/sql/operations.go | 101 + arm/sql/recommendedelasticpools.go | 37 +- arm/sql/servers.go | 55 +- arm/sql/version.go | 4 +- arm/storage/accounts.go | 439 ++- arm/storage/client.go | 11 +- arm/storage/models.go | 229 +- arm/storage/{usageoperations.go => usage.go} | 39 +- arm/storage/version.go | 35 +- arm/storageimportexport/client.go | 65 +- arm/storageimportexport/jobs.go | 208 +- arm/storageimportexport/version.go | 35 +- arm/trafficmanager/endpoints.go | 24 +- arm/trafficmanager/profiles.go | 42 +- arm/trafficmanager/version.go | 4 +- arm/web/apps.go | 2622 ++++++++++++----- arm/web/appservicecertificateorders.go | 222 +- arm/web/appserviceenvironments.go | 465 +-- arm/web/appserviceplans.go | 213 +- arm/web/certificates.go | 425 +-- arm/web/client.go | 66 +- arm/web/deletedwebapps.go | 12 +- arm/web/domains.go | 135 +- arm/web/models.go | 129 +- arm/web/provider.go | 160 + arm/web/recommendations.go | 42 +- arm/web/topleveldomains.go | 18 +- arm/web/version.go | 4 +- datalake-store/filesystem/filesystemgroup.go | 132 +- datalake-store/filesystem/version.go | 4 +- dataplane/keyvault/client.go | 610 ++-- dataplane/keyvault/version.go | 35 +- management/version.go | 2 +- sample.go | 72 + 495 files changed, 74506 insertions(+), 14566 deletions(-) create mode 100644 arm/advisor/client.go create mode 100644 arm/advisor/models.go create mode 100644 arm/advisor/operations.go create mode 100644 arm/advisor/recommendations.go create mode 100644 arm/advisor/suppressions.go create mode 100644 arm/advisor/version.go create mode 100644 arm/apimanagement/apiexport.go create mode 100644 arm/apimanagement/apioperationspolicy.go create mode 100644 arm/apimanagement/apipolicy.go create mode 100644 arm/apimanagement/networkstatus.go create mode 100644 arm/apimanagement/operations.go create mode 100644 arm/apimanagement/productpolicy.go create mode 100644 arm/apimanagement/properties.go create mode 100644 arm/apimanagement/services.go create mode 100644 arm/apimanagement/tenantpolicy.go create mode 100644 arm/appinsights/client.go create mode 100644 arm/appinsights/components.go create mode 100644 arm/appinsights/models.go create mode 100644 arm/appinsights/operations.go create mode 100644 arm/appinsights/version.go create mode 100644 arm/appinsights/webtests.go create mode 100644 arm/automation/account.go create mode 100644 arm/automation/activity.go create mode 100644 arm/automation/agentregistrationinformation.go create mode 100644 arm/automation/certificate.go create mode 100644 arm/automation/client.go create mode 100644 arm/automation/connection.go create mode 100644 arm/automation/connectiontype.go create mode 100644 arm/automation/credential.go create mode 100644 arm/automation/dsccompilationjob.go create mode 100644 arm/automation/dscconfiguration.go create mode 100644 arm/automation/dscnode.go create mode 100644 arm/automation/dscnodeconfiguration.go create mode 100644 arm/automation/fields.go create mode 100644 arm/automation/hybridrunbookworkergroup.go create mode 100644 arm/automation/job.go create mode 100644 arm/automation/jobschedule.go create mode 100644 arm/automation/jobstream.go create mode 100644 arm/automation/models.go create mode 100644 arm/automation/module.go create mode 100644 arm/automation/nodereports.go create mode 100644 arm/automation/objectdatatypes.go create mode 100644 arm/automation/operations.go create mode 100644 arm/automation/runbook.go create mode 100644 arm/automation/runbookdraft.go create mode 100644 arm/automation/schedule.go create mode 100644 arm/automation/statistics.go create mode 100644 arm/automation/testjobs.go create mode 100644 arm/automation/testjobstreams.go create mode 100644 arm/automation/usages.go create mode 100644 arm/automation/variable.go create mode 100644 arm/automation/version.go create mode 100644 arm/automation/webhook.go create mode 100644 arm/billing/periods.go create mode 100644 arm/consumption/client.go create mode 100644 arm/consumption/models.go create mode 100644 arm/consumption/operations.go create mode 100644 arm/consumption/usagedetails.go create mode 100644 arm/consumption/version.go create mode 100644 arm/containerregistry/operations.go create mode 100644 arm/containerregistry/replications.go create mode 100644 arm/containerregistry/webhooks.go create mode 100644 arm/devtestlabs/armtemplates.go rename arm/devtestlabs/{artifactoperations.go => artifacts.go} (56%) rename arm/devtestlabs/{artifactsourceoperations.go => artifactsources.go} (50%) delete mode 100644 arm/devtestlabs/costoperations.go create mode 100644 arm/devtestlabs/costs.go delete mode 100644 arm/devtestlabs/customimageoperations.go create mode 100644 arm/devtestlabs/customimages.go create mode 100644 arm/devtestlabs/disks.go create mode 100644 arm/devtestlabs/environments.go delete mode 100644 arm/devtestlabs/formulaoperations.go create mode 100644 arm/devtestlabs/formulas.go rename arm/devtestlabs/{galleryimageoperations.go => galleryimages.go} (55%) create mode 100644 arm/devtestlabs/globalschedules.go delete mode 100644 arm/devtestlabs/laboperations.go create mode 100644 arm/devtestlabs/labs.go create mode 100644 arm/devtestlabs/notificationchannels.go rename arm/devtestlabs/{policyoperations.go => policies.go} (51%) rename arm/devtestlabs/{policyset.go => policysets.go} (59%) delete mode 100644 arm/devtestlabs/scheduleoperations.go create mode 100644 arm/devtestlabs/schedules.go create mode 100644 arm/devtestlabs/secrets.go create mode 100644 arm/devtestlabs/servicerunners.go create mode 100644 arm/devtestlabs/users.go delete mode 100644 arm/devtestlabs/virtualmachine.go create mode 100644 arm/devtestlabs/virtualmachines.go create mode 100644 arm/devtestlabs/virtualmachineschedules.go delete mode 100644 arm/devtestlabs/virtualnetworkoperations.go create mode 100644 arm/devtestlabs/virtualnetworks.go create mode 100644 arm/hdinsight/applications.go create mode 100644 arm/hdinsight/client.go create mode 100644 arm/hdinsight/clusters.go create mode 100644 arm/hdinsight/configurations.go create mode 100644 arm/hdinsight/extension.go create mode 100644 arm/hdinsight/location.go create mode 100644 arm/hdinsight/models.go create mode 100644 arm/hdinsight/operations.go create mode 100644 arm/hdinsight/scriptactions.go create mode 100644 arm/hdinsight/scriptexecutionhistory.go create mode 100644 arm/hdinsight/version.go create mode 100644 arm/insights/alertruleincidents.go create mode 100644 arm/insights/alertrules.go create mode 100644 arm/insights/autoscalesettings.go create mode 100644 arm/insights/client.go create mode 100644 arm/insights/logprofiles.go create mode 100644 arm/insights/models.go create mode 100644 arm/insights/servicediagnosticsettings.go create mode 100644 arm/insights/version.go create mode 100644 arm/monitor/activitylogalerts.go create mode 100644 arm/monitor/alertruleincidents.go create mode 100644 arm/monitor/alertrules.go create mode 100644 arm/monitor/autoscalesettings.go create mode 100644 arm/monitor/client.go create mode 100644 arm/monitor/logprofiles.go create mode 100644 arm/monitor/models.go create mode 100644 arm/monitor/servicediagnosticsettings.go create mode 100644 arm/monitor/version.go create mode 100644 arm/network/bgpservicecommunities.go create mode 100644 arm/network/packetcaptures.go create mode 100644 arm/network/routefilterrules.go create mode 100644 arm/network/routefilters.go create mode 100644 arm/network/watchers.go create mode 100644 arm/recoveryservices/operations.go create mode 100644 arm/recoveryservices/vaultextendedinfo.go create mode 100644 arm/recoveryservicesbackup/backupengines.go create mode 100644 arm/recoveryservicesbackup/backupjobs.go create mode 100644 arm/recoveryservicesbackup/backupoperationresults.go create mode 100644 arm/recoveryservicesbackup/backupoperationstatuses.go create mode 100644 arm/recoveryservicesbackup/backuppolicies.go create mode 100644 arm/recoveryservicesbackup/backupprotectableitems.go create mode 100644 arm/recoveryservicesbackup/backupprotecteditems.go create mode 100644 arm/recoveryservicesbackup/backupprotectioncontainers.go create mode 100644 arm/recoveryservicesbackup/backupresourcestorageconfigs.go create mode 100644 arm/recoveryservicesbackup/backupresourcevaultconfigs.go create mode 100644 arm/recoveryservicesbackup/backups.go create mode 100644 arm/recoveryservicesbackup/backupusagesummaries.go create mode 100644 arm/recoveryservicesbackup/client.go create mode 100644 arm/recoveryservicesbackup/exportjobsoperationresults.go create mode 100644 arm/recoveryservicesbackup/itemlevelrecoveryconnections.go create mode 100644 arm/recoveryservicesbackup/jobcancellations.go create mode 100644 arm/recoveryservicesbackup/jobdetails.go create mode 100644 arm/recoveryservicesbackup/joboperationresults.go create mode 100644 arm/recoveryservicesbackup/jobs.go create mode 100644 arm/recoveryservicesbackup/models.go create mode 100644 arm/recoveryservicesbackup/operations.go create mode 100644 arm/recoveryservicesbackup/protecteditemoperationresults.go create mode 100644 arm/recoveryservicesbackup/protecteditemoperationstatuses.go create mode 100644 arm/recoveryservicesbackup/protecteditems.go create mode 100644 arm/recoveryservicesbackup/protectioncontaineroperationresults.go create mode 100644 arm/recoveryservicesbackup/protectioncontainerrefreshoperationresults.go create mode 100644 arm/recoveryservicesbackup/protectioncontainers.go create mode 100644 arm/recoveryservicesbackup/protectionpolicies.go create mode 100644 arm/recoveryservicesbackup/protectionpolicyoperationresults.go create mode 100644 arm/recoveryservicesbackup/protectionpolicyoperationstatuses.go create mode 100644 arm/recoveryservicesbackup/recoverypoints.go create mode 100644 arm/recoveryservicesbackup/restores.go create mode 100644 arm/recoveryservicesbackup/securitypins.go create mode 100644 arm/recoveryservicesbackup/version.go create mode 100644 arm/relay/client.go create mode 100644 arm/relay/hybridconnections.go create mode 100644 arm/relay/models.go create mode 100644 arm/relay/namespaces.go create mode 100644 arm/relay/operations.go create mode 100644 arm/relay/version.go create mode 100644 arm/relay/wcfrelays.go create mode 100644 arm/resourcehealth/availabilitystatuses.go create mode 100644 arm/resourcehealth/client.go create mode 100644 arm/resourcehealth/models.go create mode 100644 arm/resourcehealth/operations.go create mode 100644 arm/resourcehealth/version.go rename arm/resources/features/{features.go => featuresgroup.go} (61%) rename arm/resources/subscriptions/{subscriptions.go => subscriptionsgroup.go} (60%) create mode 100644 arm/servicefabric/client.go create mode 100644 arm/servicefabric/clusters.go create mode 100644 arm/servicefabric/clusterversions.go create mode 100644 arm/servicefabric/models.go create mode 100644 arm/servicefabric/operations.go create mode 100644 arm/servicefabric/version.go create mode 100644 arm/sql/capabilities.go create mode 100644 arm/sql/firewallrules.go create mode 100644 arm/sql/operations.go rename arm/storage/{usageoperations.go => usage.go} (60%) create mode 100644 arm/web/provider.go create mode 100644 sample.go diff --git a/Gododir/gen.go b/Gododir/gen.go index 6fe271f01573..34e4f49b6bb9 100644 --- a/Gododir/gen.go +++ b/Gododir/gen.go @@ -27,6 +27,7 @@ type service struct { Swagger string SubServices []service Modeler modeler + Extension extension } type modeler string @@ -36,6 +37,13 @@ const ( compSwagger modeler = "CompositeSwagger" ) +type extension string + +const ( + md extension = "md" + json extension = "json" +) + type mapping struct { Plane string InputPrefix string @@ -54,23 +62,33 @@ var ( Plane: "arm", InputPrefix: "arm-", Services: []service{ + { + Name: "advisor", + Version: "2017-04-19", + }, { Name: "analysisservices", Version: "2016-05-16", }, { Name: "apimanagement", - Version: "2016-07-07", + Swagger: "compositeApiManagementClient", + Modeler: compSwagger, }, { - Name: "apimdeployment", - Version: "2016-07-07", - Input: "apimanagement", + Name: "appinsights", + Swagger: "compositeAppInsightsManagementClient", + Modeler: compSwagger, }, { Name: "authorization", Version: "2015-07-01", }, + { + Name: "automation", + Swagger: "compositeAutomation", + Modeler: compSwagger, + }, { Name: "batch", Version: "2017-01-01", @@ -78,14 +96,16 @@ var ( }, { Name: "billing", - Version: "2017-02-27-preview", + Version: "2017-04-24-preview", }, { Name: "cdn", Version: "2016-10-02", }, { - Name: "cognitiveservices", + // bug in AutoRest (duplicated files) + Name: "cognitiveservices", + // Version: "2017-04-18", Version: "2016-02-01-preview", }, { @@ -102,23 +122,27 @@ var ( Swagger: "containerService", Input: "compute", }, + { + Name: "consumption", + Version: "2017-04-24-preview", + }, { Name: "containerregistry", - Version: "2017-03-01", + Version: "2017-06-01-preview", }, { Name: "customer-insights", Version: "2017-01-01", }, - // { - // Name: "datalake-analytics", - // SubServices: []service{ - // { - // Name: "account", - // Version: "2016-11-01", - // }, - // }, - // }, + { + Name: "datalake-analytics", + SubServices: []service{ + { + Name: "account", + Version: "2016-11-01", + }, + }, + }, { Name: "datalake-store", SubServices: []service{ @@ -154,13 +178,19 @@ var ( }, { Name: "graphrbac", - Version: "1.6", - // Composite swagger + Swagger: "compositeGraphRbacManagementClient", + Modeler: compSwagger, + }, + { + Name: "hdinsight", + Swagger: "compositeHDInsight", + Modeler: compSwagger, + }, + { + Name: "insights", + Swagger: "compositeInsightsManagementClient", + Modeler: compSwagger, }, - // { - // Name: "insights", - // // Composite swagger - // }, { Name: "intune", Version: "2015-01-14-preview", @@ -176,7 +206,6 @@ var ( { Name: "logic", Version: "2016-06-01", - // composite swagger }, { Name: "machinelearning", @@ -189,7 +218,7 @@ var ( }, { Name: "webservices", - Version: "2016-05-01-preview", + Version: "2017-01-01", Input: "machinelearning", }, }, @@ -204,42 +233,59 @@ var ( Version: "2014-12-01", Swagger: "mobile-engagement", }, - // { - // Name: "network", - // Version: "2016-09-01", - // }, { - Name: "networkwatcher", - Version: "2016-12-01", - Swagger: "networkWatcher", - Input: "network", + Name: "monitor", + Swagger: "compositeMonitorManagementClient", + Modeler: compSwagger, + }, + { + Name: "network", + Swagger: "compositeNetworkClient", + Modeler: compSwagger, }, { Name: "notificationhubs", - Version: "2016-03-01", + Version: "2017-04-01", }, { - Name: "operationalinsights", + // bug in the Go generator https://github.com/Azure/autorest/issues/2219 + Name: "operationalinsights", + // Swagger: "compositeOperationalInsights", + // Modeler: compSwagger, Version: "2015-11-01-preview", - Swagger: "OperationalInsights", }, { Name: "powerbiembedded", Version: "2016-01-29", }, { - Name: "recoveryservices", + // bug in the go generator + Name: "recoveryservices", + // Swagger: "compositeRecoveryServicesClient", + // Modeler: compSwagger, Version: "2016-06-01", + Swagger: "vaults", + }, + { + // When using the readme.md, there is an exception in the modeler + Name: "recoveryservicesbackup", + Version: "2016-12-01", + // Swagger: "readme", + // Extension: md, + Swagger: "backupManagement", }, - // { - // Name: "recoveryservicesbackup", - // Version: "2016-06-01", - // // composite swagger - // }, { Name: "redis", Version: "2016-04-01", }, + { + Name: "relay", + Version: "2016-07-01", + }, + { + Name: "resourcehealth", + Version: "2015-01-01", + }, { Name: "resources", SubServices: []service{ @@ -262,6 +308,7 @@ var ( { Name: "resources", Version: "2016-09-01", + // Version: "2017-05-10", }, { Name: "subscriptions", @@ -281,19 +328,23 @@ var ( Name: "servermanagement", Version: "2016-07-01-preview", }, + { + Name: "service-map", + Version: "2015-11-01-preview", + Swagger: "arm-service-map", + }, { Name: "servicebus", Version: "2015-08-01", }, { - Name: "service-map", - Version: "2015-11-01-preview", - Swagger: "arm-service-map", + Name: "servicefabric", + Version: "2016-09-01", }, { Name: "sql", - Version: "2014-04-01", - Swagger: "sql.core", + Swagger: "compositeSql", + Modeler: compSwagger, }, { Name: "storage", @@ -303,6 +354,17 @@ var ( Name: "storageimportexport", Version: "2016-11-01", }, + // { + // Too soon to release + // Name: "storsimple8000series", + // Version: "2017-06-01". + // Swagger: "storsimple", + // }, + // { + // error in the modeler + // Name: "timeseriesinsights", + // Version: "2017-02-28-preview", + // }, { Name: "trafficmanager", Version: "2015-11-01", @@ -314,74 +376,63 @@ var ( }, }, }, - //{ - // Plane: "dataplane", - // InputPrefix: "", - // Services: []service{ - // { - // Name: "batch", - // Version: "2016-07-01.3.1", - // Swagger: "BatchService", - // }, - // { - // Name: "insights", - // // composite swagger - // }, - // { - // Name: "keyvault", - // Version: "2015-06-01", - // }, - // { - // Name: "search", - // SubServices: []service{ - // { - // Name: "searchindex", - // Version: "2015-02-28", - // Input: "search", - // }, - // { - // Name: "searchservice", - // Version: "2015-02-28", - // Input: "search", - // }, - // }, - // }, - // { - // Name: "servicefabric", - // Version: "2016-01-28", - // }, - // }, - //}, { - Plane: "", - InputPrefix: "arm-", + Plane: "dataplane", + InputPrefix: "", Services: []service{ - // { - // Name: "batch", - // Version: "2016-07-01.3.1", - // Swagger: "BatchService", - // }, - // { - // Name: "insights", - // // composite swagger - // }, + // { + // Name: "batch", + // Version: "2017-01-01.4.0", + // Swagger: "BatchService", + // }, + // { + // Name: "insights", + // Swagger: "compositeInsightsClient", + // Modeler: compSwagger, + // }, { Name: "keyvault", Version: "2016-10-01", }, + // { + // Name: "monitor", + // Swagger: "compositeMonitorClient", + // Modeler: compSwagger, + // }, // { // Name: "search", // SubServices: []service{ // { // Name: "searchindex", - // Version: "2015-02-28", + // Version: "2016-09-01", // Input: "search", // }, // { // Name: "searchservice", - // Version: "2015-02-28", + // Version: "2016-09-01", // Input: "search", // }, + // }, + // }, + // { + // Name: "servicefabric", + // Version: "2016-01-28", + // }, + }, + }, + { + Plane: "", + InputPrefix: "arm-", + Services: []service{ + { + Name: "datalake-store", + SubServices: []service{ + { + Name: "filesystem", + Version: "2016-11-01", + }, + }, + }, // { // Name: "datalake-analytics", // SubServices: []service{ @@ -394,40 +445,9 @@ var ( // Version: "2016-11-01", // }, // }, - // { - // Name: "servicefabric", - // Version: "2016-01-28", - // }, + // }, }, }, - // { - // Plane: "", - // InputPrefix: "arm-", - // Services: []service{ - // { - // Name: "datalake-store", - // SubServices: []service{ - // { - // Name: "filesystem", - // Version: "2016-11-01", - // }, - // }, - // }, - // { - // Name: "datalake-analytics", - // SubServices: []service{ - // { - // Name: "catalog", - // Version: "2016-11-01", - // }, - // { - // Name: "job", - // Version: "2016-11-01", - // }, - // }, - // }, - // }, - // }, } ) @@ -446,17 +466,27 @@ func initAndAddService(service *service, inputPrefix, plane string) { if service.Swagger == "" { service.Swagger = service.Name } + if service.Extension == "" { + service.Extension = json + } packages := append(service.Packages, service.Name) service.TaskName = fmt.Sprintf("%s>%s", plane, strings.Join(packages, ">")) service.Fullname = filepath.Join(plane, strings.Join(packages, "/")) if service.Modeler == compSwagger { service.Input = filepath.Join(inputPrefix+strings.Join(packages, "/"), service.Swagger) } else { + input := []string{} if service.Input == "" { - service.Input = filepath.Join(inputPrefix+strings.Join(packages, "/"), service.Version, "swagger", service.Swagger) + input = append(input, inputPrefix+strings.Join(packages, "/")) } else { - service.Input = filepath.Join(inputPrefix+service.Input, service.Version, "swagger", service.Swagger) + input = append(input, inputPrefix+service.Input) + } + input = append(input, service.Version) + if service.Extension == json { + input = append(input, "swagger") } + input = append(input, service.Swagger) + service.Input = filepath.Join(input...) service.Modeler = swagger } service.Namespace = filepath.Join("github.com", "Azure", "azure-sdk-for-go", service.Fullname) @@ -504,9 +534,9 @@ func generate(service *service) { fmt.Printf("Generating %s...\n\n", service.Fullname) delete(service) - autorest := exec.Command( + autorest := exec.Command("gulp", "autorest", - "-Input", filepath.Join(swaggersDir, "azure-rest-api-specs", service.Input+".json"), + "-Input", filepath.Join(swaggersDir, "azure-rest-api-specs", service.Input+"."+string(service.Extension)), "-CodeGenerator", "Go", "-Header", "MICROSOFT_APACHE", "-Namespace", service.Name, diff --git a/arm/advisor/client.go b/arm/advisor/client.go new file mode 100644 index 000000000000..eccfe2c63ad1 --- /dev/null +++ b/arm/advisor/client.go @@ -0,0 +1,53 @@ +// Package advisor implements the Azure ARM Advisor service API version +// 2017-04-19. +// +// REST APIs for Azure Advisor +package advisor + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Advisor + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Advisor. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/arm/advisor/models.go b/arm/advisor/models.go new file mode 100644 index 000000000000..9b861c068e6d --- /dev/null +++ b/arm/advisor/models.go @@ -0,0 +1,188 @@ +package advisor + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/satori/uuid" + "net/http" +) + +// Category enumerates the values for category. +type Category string + +const ( + // Cost specifies the cost state for category. + Cost Category = "Cost" + // HighAvailability specifies the high availability state for category. + HighAvailability Category = "HighAvailability" + // Performance specifies the performance state for category. + Performance Category = "Performance" + // Security specifies the security state for category. + Security Category = "Security" +) + +// Impact enumerates the values for impact. +type Impact string + +const ( + // High specifies the high state for impact. + High Impact = "High" + // Low specifies the low state for impact. + Low Impact = "Low" + // Medium specifies the medium state for impact. + Medium Impact = "Medium" +) + +// Risk enumerates the values for risk. +type Risk string + +const ( + // Error specifies the error state for risk. + Error Risk = "Error" + // None specifies the none state for risk. + None Risk = "None" + // Warning specifies the warning state for risk. + Warning Risk = "Warning" +) + +// OperationDisplayInfo is the operation supported by Advisor. +type OperationDisplayInfo struct { + Description *string `json:"description,omitempty"` + Operation *string `json:"operation,omitempty"` + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` +} + +// OperationEntity is the operation supported by Advisor. +type OperationEntity struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplayInfo `json:"display,omitempty"` +} + +// OperationEntityListResult is the list of Advisor operations. +type OperationEntityListResult struct { + autorest.Response `json:"-"` + NextLink *string `json:"nextLink,omitempty"` + Value *[]OperationEntity `json:"value,omitempty"` +} + +// OperationEntityListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationEntityListResult) OperationEntityListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RecommendationProperties is the properties of the recommendation. +type RecommendationProperties struct { + Category Category `json:"category,omitempty"` + Impact Impact `json:"impact,omitempty"` + ImpactedField *string `json:"impactedField,omitempty"` + ImpactedValue *string `json:"impactedValue,omitempty"` + LastUpdated *date.Time `json:"lastUpdated,omitempty"` + Metadata *map[string]*map[string]interface{} `json:"metadata,omitempty"` + RecommendationTypeID *string `json:"recommendationTypeId,omitempty"` + Risk Risk `json:"risk,omitempty"` + ShortDescription *ShortDescription `json:"shortDescription,omitempty"` + SuppressionIds *[]uuid.UUID `json:"suppressionIds,omitempty"` +} + +// Resource is an Azure resource. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// ResourceRecommendationBase is advisor Recommendation. +type ResourceRecommendationBase struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *RecommendationProperties `json:"properties,omitempty"` +} + +// ResourceRecommendationBaseListResult is the list of Advisor recommendations. +type ResourceRecommendationBaseListResult struct { + autorest.Response `json:"-"` + NextLink *string `json:"nextLink,omitempty"` + Value *[]ResourceRecommendationBase `json:"value,omitempty"` +} + +// ResourceRecommendationBaseListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResourceRecommendationBaseListResult) ResourceRecommendationBaseListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ShortDescription is a summary of the recommendation. +type ShortDescription struct { + Problem *string `json:"problem,omitempty"` + Solution *string `json:"solution,omitempty"` +} + +// SuppressionContract is the details of the snoozed or dismissed rule; for +// example, the duration, name, and GUID associated with the rule. +type SuppressionContract struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *SuppressionProperties `json:"properties,omitempty"` +} + +// SuppressionContractListResult is the list of Advisor suppressions. +type SuppressionContractListResult struct { + autorest.Response `json:"-"` + NextLink *string `json:"nextLink,omitempty"` + Value *[]SuppressionContract `json:"value,omitempty"` +} + +// SuppressionContractListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client SuppressionContractListResult) SuppressionContractListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// SuppressionProperties is the properties of the suppression. +type SuppressionProperties struct { + SuppressionID *string `json:"suppressionId,omitempty"` + TTL *string `json:"ttl,omitempty"` +} diff --git a/arm/advisor/operations.go b/arm/advisor/operations.go new file mode 100644 index 000000000000..611dafec8a89 --- /dev/null +++ b/arm/advisor/operations.go @@ -0,0 +1,122 @@ +package advisor + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the rEST APIs for Azure Advisor +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all the available Advisor REST API operations. +func (client OperationsClient) List() (result OperationEntityListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Advisor/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationEntityListResult) (result OperationEntityListResult, err error) { + req, err := lastResults.OperationEntityListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/advisor/recommendations.go b/arm/advisor/recommendations.go new file mode 100644 index 000000000000..beaa8e74cb9b --- /dev/null +++ b/arm/advisor/recommendations.go @@ -0,0 +1,338 @@ +package advisor + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/satori/uuid" + "net/http" +) + +// RecommendationsClient is the rEST APIs for Azure Advisor +type RecommendationsClient struct { + ManagementClient +} + +// NewRecommendationsClient creates an instance of the RecommendationsClient +// client. +func NewRecommendationsClient(subscriptionID string) RecommendationsClient { + return NewRecommendationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecommendationsClientWithBaseURI creates an instance of the +// RecommendationsClient client. +func NewRecommendationsClientWithBaseURI(baseURI string, subscriptionID string) RecommendationsClient { + return RecommendationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Generate initiates the recommendation generation or computation process for +// a subscription. This operation is asynchronous. The generated +// recommendations are stored in a cache in the Advisor service. +func (client RecommendationsClient) Generate() (result autorest.Response, err error) { + req, err := client.GeneratePreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Generate", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Generate", resp, "Failure sending request") + return + } + + result, err = client.GenerateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Generate", resp, "Failure responding to request") + } + + return +} + +// GeneratePreparer prepares the Generate request. +func (client RecommendationsClient) GeneratePreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GenerateSender sends the Generate request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendationsClient) GenerateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GenerateResponder handles the response to the Generate request. The method always +// closes the http.Response Body. +func (client RecommendationsClient) GenerateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get obtains details of a cached recommendation. +// +// resourceURI is the fully qualified Azure Resource Manager identifier of the +// resource to which the recommendation applies. recommendationID is the +// recommendation ID. +func (client RecommendationsClient) Get(resourceURI string, recommendationID string) (result ResourceRecommendationBase, err error) { + req, err := client.GetPreparer(resourceURI, recommendationID) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecommendationsClient) GetPreparer(resourceURI string, recommendationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecommendationsClient) GetResponder(resp *http.Response) (result ResourceRecommendationBase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGenerateStatus retrieves the status of the recommendation computation or +// generation process. Invoke this API after calling the generation +// recommendation. The URI of this API is returned in the Location field of the +// response header. +// +// operationID is the operation ID, which can be found from the Location field +// in the generate recommendation response header. +func (client RecommendationsClient) GetGenerateStatus(operationID uuid.UUID) (result autorest.Response, err error) { + req, err := client.GetGenerateStatusPreparer(operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "GetGenerateStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetGenerateStatusSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "GetGenerateStatus", resp, "Failure sending request") + return + } + + result, err = client.GetGenerateStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "GetGenerateStatus", resp, "Failure responding to request") + } + + return +} + +// GetGenerateStatusPreparer prepares the GetGenerateStatus request. +func (client RecommendationsClient) GetGenerateStatusPreparer(operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationId": autorest.Encode("path", operationID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetGenerateStatusSender sends the GetGenerateStatus request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendationsClient) GetGenerateStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetGenerateStatusResponder handles the response to the GetGenerateStatus request. The method always +// closes the http.Response Body. +func (client RecommendationsClient) GetGenerateStatusResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// List obtains cached recommendations for a subscription. The recommendations +// are generated or computed by invoking generateRecommendations. +// +// filter is the filter to apply to the recommendations. top is the number of +// recommendations per page if a paged version of this API is being used. +// skipToken is the page-continuation token to use with a paged version of this +// API. +func (client RecommendationsClient) List(filter string, top *int32, skipToken string) (result ResourceRecommendationBaseListResult, err error) { + req, err := client.ListPreparer(filter, top, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RecommendationsClient) ListPreparer(filter string, top *int32, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RecommendationsClient) ListResponder(resp *http.Response) (result ResourceRecommendationBaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client RecommendationsClient) ListNextResults(lastResults ResourceRecommendationBaseListResult) (result ResourceRecommendationBaseListResult, err error) { + req, err := lastResults.ResourceRecommendationBaseListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.RecommendationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/advisor/suppressions.go b/arm/advisor/suppressions.go new file mode 100644 index 000000000000..ec0c6c494d34 --- /dev/null +++ b/arm/advisor/suppressions.go @@ -0,0 +1,345 @@ +package advisor + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// SuppressionsClient is the rEST APIs for Azure Advisor +type SuppressionsClient struct { + ManagementClient +} + +// NewSuppressionsClient creates an instance of the SuppressionsClient client. +func NewSuppressionsClient(subscriptionID string) SuppressionsClient { + return NewSuppressionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSuppressionsClientWithBaseURI creates an instance of the +// SuppressionsClient client. +func NewSuppressionsClientWithBaseURI(baseURI string, subscriptionID string) SuppressionsClient { + return SuppressionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create enables the snoozed or dismissed attribute of a recommendation. The +// snoozed or dismissed attribute is referred to as a suppression. Use this API +// to create or update the snoozed or dismissed status of a recommendation. +// +// resourceURI is the fully qualified Azure Resource Manager identifier of the +// resource to which the recommendation applies. recommendationID is the +// recommendation ID. name is the name of the suppression. suppressionContract +// is the snoozed or dismissed attribute; for example, the snooze duration. +func (client SuppressionsClient) Create(resourceURI string, recommendationID string, name string, suppressionContract SuppressionContract) (result SuppressionContract, err error) { + req, err := client.CreatePreparer(resourceURI, recommendationID, name, suppressionContract) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SuppressionsClient) CreatePreparer(resourceURI string, recommendationID string, name string, suppressionContract SuppressionContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", pathParameters), + autorest.WithJSON(suppressionContract), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SuppressionsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SuppressionsClient) CreateResponder(resp *http.Response) (result SuppressionContract, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete enables the activation of a snoozed or dismissed recommendation. The +// snoozed or dismissed attribute of a recommendation is referred to as a +// suppression. +// +// resourceURI is the fully qualified Azure Resource Manager identifier of the +// resource to which the recommendation applies. recommendationID is the +// recommendation ID. name is the name of the suppression. +func (client SuppressionsClient) Delete(resourceURI string, recommendationID string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceURI, recommendationID, name) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SuppressionsClient) DeletePreparer(resourceURI string, recommendationID string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SuppressionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SuppressionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get obtains the details of a suppression. +// +// resourceURI is the fully qualified Azure Resource Manager identifier of the +// resource to which the recommendation applies. recommendationID is the +// recommendation ID. name is the name of the suppression. +func (client SuppressionsClient) Get(resourceURI string, recommendationID string, name string) (result SuppressionContract, err error) { + req, err := client.GetPreparer(resourceURI, recommendationID, name) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SuppressionsClient) GetPreparer(resourceURI string, recommendationID string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "recommendationId": autorest.Encode("path", recommendationID), + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SuppressionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SuppressionsClient) GetResponder(resp *http.Response) (result SuppressionContract, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List retrieves the list of snoozed or dismissed suppressions for a +// subscription. The snoozed or dismissed attribute of a recommendation is +// referred to as a suppression. +// +// top is the number of suppressions per page if a paged version of this API is +// being used. skipToken is the page-continuation token to use with a paged +// version of this API. +func (client SuppressionsClient) List(top *int32, skipToken string) (result SuppressionContractListResult, err error) { + req, err := client.ListPreparer(top, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SuppressionsClient) ListPreparer(top *int32, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-19" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SuppressionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SuppressionsClient) ListResponder(resp *http.Response) (result SuppressionContractListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client SuppressionsClient) ListNextResults(lastResults SuppressionContractListResult) (result SuppressionContractListResult, err error) { + req, err := lastResults.SuppressionContractListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "advisor.SuppressionsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/advisor/version.go b/arm/advisor/version.go new file mode 100644 index 000000000000..2385f9b01254 --- /dev/null +++ b/arm/advisor/version.go @@ -0,0 +1,29 @@ +package advisor + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.0.0-beta arm-advisor/2017-04-19" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.0.0-beta" +} diff --git a/arm/analysisservices/models.go b/arm/analysisservices/models.go index 1ca5d54a5073..96fb36496cd5 100755 --- a/arm/analysisservices/models.go +++ b/arm/analysisservices/models.go @@ -56,8 +56,14 @@ const ( type SkuName string const ( + // B1 specifies the b1 state for sku name. + B1 SkuName = "B1" + // B2 specifies the b2 state for sku name. + B2 SkuName = "B2" // D1 specifies the d1 state for sku name. D1 SkuName = "D1" + // S0 specifies the s0 state for sku name. + S0 SkuName = "S0" // S1 specifies the s1 state for sku name. S1 SkuName = "S1" // S2 specifies the s2 state for sku name. @@ -70,6 +76,8 @@ const ( type SkuTier string const ( + // Basic specifies the basic state for sku tier. + Basic SkuTier = "Basic" // Development specifies the development state for sku tier. Development SkuTier = "Development" // Standard specifies the standard state for sku tier. diff --git a/arm/analysisservices/servers.go b/arm/analysisservices/servers.go index bbf334407f54..70e0e448baf8 100755 --- a/arm/analysisservices/servers.go +++ b/arm/analysisservices/servers.go @@ -53,7 +53,9 @@ func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersC // server. It must be a minimum of 3 characters, and a maximum of 63. // serverParameters is contains the information used to provision the Analysis // Services server. -func (client ServersClient) Create(resourceGroupName string, serverName string, serverParameters Server, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ServersClient) Create(resourceGroupName string, serverName string, serverParameters Server, cancel <-chan struct{}) (<-chan Server, <-chan error) { + resultChan := make(chan Server, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -63,26 +65,40 @@ func (client ServersClient) Create(resourceGroupName string, serverName string, Constraints: []validation.Constraint{{Target: "serverName", Name: validation.MaxLength, Rule: 63, Chain: nil}, {Target: "serverName", Name: validation.MinLength, Rule: 3, Chain: nil}, {Target: "serverName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Create") - } - - req, err := client.CreatePreparer(resourceGroupName, serverName, serverParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Create", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Server + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, serverName, serverParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -118,13 +134,14 @@ func (client ServersClient) CreateSender(req *http.Request) (*http.Response, err // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client ServersClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ServersClient) CreateResponder(resp *http.Response) (result Server, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -137,7 +154,9 @@ func (client ServersClient) CreateResponder(resp *http.Response) (result autores // Analysis Services server is part. This name must be at least 1 character in // length, and no more than 90. serverName is the name of the Analysis Services // server. It must be at least 3 characters in length, and no more than 63. -func (client ServersClient) Delete(resourceGroupName string, serverName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ServersClient) Delete(resourceGroupName string, serverName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -147,26 +166,40 @@ func (client ServersClient) Delete(resourceGroupName string, serverName string, Constraints: []validation.Constraint{{Target: "serverName", Name: validation.MaxLength, Rule: 63, Chain: nil}, {Target: "serverName", Name: validation.MinLength, Rule: 3, Chain: nil}, {Target: "serverName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Delete") - } - - req, err := client.DeletePreparer(resourceGroupName, serverName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Delete", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, serverName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -231,13 +264,15 @@ func (client ServersClient) GetDetails(resourceGroupName string, serverName stri req, err := client.GetDetailsPreparer(resourceGroupName, serverName) if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "GetDetails", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "GetDetails", nil, "Failure preparing request") + return } resp, err := client.GetDetailsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "GetDetails", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "GetDetails", resp, "Failure sending request") + return } result, err = client.GetDetailsResponder(resp) @@ -292,13 +327,15 @@ func (client ServersClient) GetDetailsResponder(resp *http.Response) (result Ser func (client ServersClient) List() (result Servers, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -364,13 +401,15 @@ func (client ServersClient) ListByResourceGroup(resourceGroupName string) (resul req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -429,7 +468,9 @@ func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (r // Analysis Services server is part. This name must be at least 1 character in // length, and no more than 90. serverName is the name of the Analysis Services // server. It must be at least 3 characters in length, and no more than 63. -func (client ServersClient) Resume(resourceGroupName string, serverName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ServersClient) Resume(resourceGroupName string, serverName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -439,26 +480,40 @@ func (client ServersClient) Resume(resourceGroupName string, serverName string, Constraints: []validation.Constraint{{Target: "serverName", Name: validation.MaxLength, Rule: 63, Chain: nil}, {Target: "serverName", Name: validation.MinLength, Rule: 3, Chain: nil}, {Target: "serverName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Resume") - } - - req, err := client.ResumePreparer(resourceGroupName, serverName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Resume", nil, "Failure preparing request") - } - - resp, err := client.ResumeSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Resume", resp, "Failure sending request") - } - - result, err = client.ResumeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Resume", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Resume") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ResumePreparer(resourceGroupName, serverName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Resume", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ResumePreparer prepares the Resume request. @@ -511,7 +566,9 @@ func (client ServersClient) ResumeResponder(resp *http.Response) (result autores // Analysis Services server is part. This name must be at least 1 character in // length, and no more than 90. serverName is the name of the Analysis Services // server. It must be at least 3 characters in length, and no more than 63. -func (client ServersClient) Suspend(resourceGroupName string, serverName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ServersClient) Suspend(resourceGroupName string, serverName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -521,26 +578,40 @@ func (client ServersClient) Suspend(resourceGroupName string, serverName string, Constraints: []validation.Constraint{{Target: "serverName", Name: validation.MaxLength, Rule: 63, Chain: nil}, {Target: "serverName", Name: validation.MinLength, Rule: 3, Chain: nil}, {Target: "serverName", Name: validation.Pattern, Rule: `^[a-z][a-z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Suspend") - } - - req, err := client.SuspendPreparer(resourceGroupName, serverName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Suspend", nil, "Failure preparing request") - } - - resp, err := client.SuspendSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Suspend", resp, "Failure sending request") - } - - result, err = client.SuspendResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Suspend", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "analysisservices.ServersClient", "Suspend") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.SuspendPreparer(resourceGroupName, serverName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Suspend", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // SuspendPreparer prepares the Suspend request. @@ -607,13 +678,15 @@ func (client ServersClient) Update(resourceGroupName string, serverName string, req, err := client.UpdatePreparer(resourceGroupName, serverName, serverUpdateParameters) if err != nil { - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "analysisservices.ServersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/analysisservices/version.go b/arm/analysisservices/version.go index 35700bbec833..0812f7fb681a 100755 --- a/arm/analysisservices/version.go +++ b/arm/analysisservices/version.go @@ -20,10 +20,10 @@ package analysisservices // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-analysisservices/2016-05-16" + return "Azure-SDK-For-Go/v10.0.0-beta arm-analysisservices/2016-05-16" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/apimanagement/apiexport.go b/arm/apimanagement/apiexport.go new file mode 100644 index 000000000000..65ceffdaaa63 --- /dev/null +++ b/arm/apimanagement/apiexport.go @@ -0,0 +1,122 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// APIExportClient is the composite Swagger for ApiManagement Client +type APIExportClient struct { + ManagementClient +} + +// NewAPIExportClient creates an instance of the APIExportClient client. +func NewAPIExportClient(subscriptionID string) APIExportClient { + return NewAPIExportClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIExportClientWithBaseURI creates an instance of the APIExportClient +// client. +func NewAPIExportClientWithBaseURI(baseURI string, subscriptionID string) APIExportClient { + return APIExportClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the details of the API specified by its identifier. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. apiID is aPI identifier. Must be unique in +// the current API Management service instance. +func (client APIExportClient) Get(resourceGroupName string, serviceName string, apiID string) (result APIExportResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIExportClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, serviceName, apiID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIExportClient) GetPreparer(resourceGroupName string, serviceName string, apiID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIExportClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIExportClient) GetResponder(resp *http.Response) (result APIExportResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/apimanagement/apioperations.go b/arm/apimanagement/apioperations.go index 7f3a331ac32e..878a5975ba05 100755 --- a/arm/apimanagement/apioperations.go +++ b/arm/apimanagement/apioperations.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// APIOperationsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// APIOperationsClient is the composite Swagger for ApiManagement Client type APIOperationsClient struct { ManagementClient } @@ -74,21 +72,21 @@ func (client APIOperationsClient) CreateOrUpdate(resourceGroupName string, servi {Target: "parameters.URLTemplate", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.URLTemplate", Name: validation.MaxLength, Rule: 1000, Chain: nil}, {Target: "parameters.URLTemplate", Name: validation.MinLength, Rule: 1, Chain: nil}, - }}, - {Target: "parameters.Description", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Description", Name: validation.MaxLength, Rule: 1000, Chain: nil}}}}}}); err != nil { + }}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate") } req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, apiID, operationID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -109,7 +107,7 @@ func (client APIOperationsClient) CreateOrUpdatePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -170,13 +168,15 @@ func (client APIOperationsClient) Delete(resourceGroupName string, serviceName s req, err := client.DeletePreparer(resourceGroupName, serviceName, apiID, operationID, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -197,7 +197,7 @@ func (client APIOperationsClient) DeletePreparer(resourceGroupName string, servi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -255,13 +255,15 @@ func (client APIOperationsClient) Get(resourceGroupName string, serviceName stri req, err := client.GetPreparer(resourceGroupName, serviceName, apiID, operationID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -282,7 +284,7 @@ func (client APIOperationsClient) GetPreparer(resourceGroupName string, serviceN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -314,7 +316,7 @@ func (client APIOperationsClient) GetResponder(resp *http.Response) (result Oper return } -// ListByAPI lists a collection of the operations for the specified API. +// ListByApis lists a collection of the operations for the specified API. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. apiID is aPI identifier. Must be unique in @@ -326,7 +328,7 @@ func (client APIOperationsClient) GetResponder(resp *http.Response) (result Oper // | description | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | // | urlTemplate | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | // top is number of records to return. skip is number of records to skip. -func (client APIOperationsClient) ListByAPI(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (result OperationCollection, err error) { +func (client APIOperationsClient) ListByApis(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (result OperationCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -342,30 +344,32 @@ func (client APIOperationsClient) ListByAPI(resourceGroupName string, serviceNam {TargetValue: skip, Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "ListByAPI") + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "ListByApis") } - req, err := client.ListByAPIPreparer(resourceGroupName, serviceName, apiID, filter, top, skip) + req, err := client.ListByApisPreparer(resourceGroupName, serviceName, apiID, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByAPI", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", nil, "Failure preparing request") + return } - resp, err := client.ListByAPISender(req) + resp, err := client.ListByApisSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByAPI", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure sending request") + return } - result, err = client.ListByAPIResponder(resp) + result, err = client.ListByApisResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByAPI", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure responding to request") } return } -// ListByAPIPreparer prepares the ListByAPI request. -func (client APIOperationsClient) ListByAPIPreparer(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (*http.Request, error) { +// ListByApisPreparer prepares the ListByApis request. +func (client APIOperationsClient) ListByApisPreparer(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "apiId": autorest.Encode("path", apiID), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -373,7 +377,7 @@ func (client APIOperationsClient) ListByAPIPreparer(resourceGroupName string, se "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -395,15 +399,15 @@ func (client APIOperationsClient) ListByAPIPreparer(resourceGroupName string, se return preparer.Prepare(&http.Request{}) } -// ListByAPISender sends the ListByAPI request. The method will close the +// ListByApisSender sends the ListByApis request. The method will close the // http.Response Body if it receives an error. -func (client APIOperationsClient) ListByAPISender(req *http.Request) (*http.Response, error) { +func (client APIOperationsClient) ListByApisSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByAPIResponder handles the response to the ListByAPI request. The method always +// ListByApisResponder handles the response to the ListByApis request. The method always // closes the http.Response Body. -func (client APIOperationsClient) ListByAPIResponder(resp *http.Response) (result OperationCollection, err error) { +func (client APIOperationsClient) ListByApisResponder(resp *http.Response) (result OperationCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -414,25 +418,25 @@ func (client APIOperationsClient) ListByAPIResponder(resp *http.Response) (resul return } -// ListByAPINextResults retrieves the next set of results, if any. -func (client APIOperationsClient) ListByAPINextResults(lastResults OperationCollection) (result OperationCollection, err error) { +// ListByApisNextResults retrieves the next set of results, if any. +func (client APIOperationsClient) ListByApisNextResults(lastResults OperationCollection) (result OperationCollection, err error) { req, err := lastResults.OperationCollectionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByAPI", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByAPISender(req) + resp, err := client.ListByApisSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByAPI", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure sending next results request") } - result, err = client.ListByAPIResponder(resp) + result, err = client.ListByApisResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByAPI", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure responding to next results request") } return @@ -444,11 +448,11 @@ func (client APIOperationsClient) ListByAPINextResults(lastResults OperationColl // of the API Management service. apiID is aPI identifier. Must be unique in // the current API Management service instance. operationID is operation // identifier within an API. Must be unique in the current API Management -// service instance. parameters is update parameters. ifMatch is eTag of the -// API Operation Entity. ETag should match the current entity state from the -// header response of the GET request or it should be * for unconditional -// update. -func (client APIOperationsClient) Update(resourceGroupName string, serviceName string, apiID string, operationID string, parameters PatchParameters, ifMatch string) (result autorest.Response, err error) { +// service instance. parameters is aPI Operation Update parameters. ifMatch is +// eTag of the API Operation Entity. ETag should match the current entity state +// from the header response of the GET request or it should be * for +// unconditional update. +func (client APIOperationsClient) Update(resourceGroupName string, serviceName string, apiID string, operationID string, parameters OperationUpdateContract, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -467,13 +471,15 @@ func (client APIOperationsClient) Update(resourceGroupName string, serviceName s req, err := client.UpdatePreparer(resourceGroupName, serviceName, apiID, operationID, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -485,7 +491,7 @@ func (client APIOperationsClient) Update(resourceGroupName string, serviceName s } // UpdatePreparer prepares the Update request. -func (client APIOperationsClient) UpdatePreparer(resourceGroupName string, serviceName string, apiID string, operationID string, parameters PatchParameters, ifMatch string) (*http.Request, error) { +func (client APIOperationsClient) UpdatePreparer(resourceGroupName string, serviceName string, apiID string, operationID string, parameters OperationUpdateContract, ifMatch string) (*http.Request, error) { pathParameters := map[string]interface{}{ "apiId": autorest.Encode("path", apiID), "operationId": autorest.Encode("path", operationID), @@ -494,7 +500,7 @@ func (client APIOperationsClient) UpdatePreparer(resourceGroupName string, servi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/apioperationspolicy.go b/arm/apimanagement/apioperationspolicy.go new file mode 100644 index 000000000000..98add99a51fc --- /dev/null +++ b/arm/apimanagement/apioperationspolicy.go @@ -0,0 +1,312 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "io" + "net/http" +) + +// APIOperationsPolicyClient is the composite Swagger for ApiManagement Client +type APIOperationsPolicyClient struct { + ManagementClient +} + +// NewAPIOperationsPolicyClient creates an instance of the +// APIOperationsPolicyClient client. +func NewAPIOperationsPolicyClient(subscriptionID string) APIOperationsPolicyClient { + return NewAPIOperationsPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIOperationsPolicyClientWithBaseURI creates an instance of the +// APIOperationsPolicyClient client. +func NewAPIOperationsPolicyClientWithBaseURI(baseURI string, subscriptionID string) APIOperationsPolicyClient { + return APIOperationsPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates policy configuration for the API Operation +// level. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. apiID is aPI identifier. Must be unique in +// the current API Management service instance. operationID is operation +// identifier within an API. Must be unique in the current API Management +// service instance. parameters is the policy contents to apply. parameters +// will be closed upon successful return. Callers should ensure closure when +// receiving an error.ifMatch is the entity state (Etag) version of the Api +// Operation policy to update. A value of "*" can be used for If-Match to +// unconditionally apply the operation. +func (client APIOperationsPolicyClient) CreateOrUpdate(resourceGroupName string, serviceName string, apiID string, operationID string, parameters io.ReadCloser, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "operationID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsPolicyClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, apiID, operationID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIOperationsPolicyClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, apiID string, operationID string, parameters io.ReadCloser, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policy", pathParameters), + autorest.WithFile(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationsPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIOperationsPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete deletes the policy configuration at the Api Operation. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. apiID is aPI identifier. Must be unique in +// the current API Management service instance. operationID is operation +// identifier within an API. Must be unique in the current API Management +// service instance. ifMatch is the entity state (Etag) version of the Api +// operation policy to update. A value of "*" can be used for If-Match to +// unconditionally apply the operation. +func (client APIOperationsPolicyClient) Delete(resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "operationID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsPolicyClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, serviceName, apiID, operationID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIOperationsPolicyClient) DeletePreparer(resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policy", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationsPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIOperationsPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the policy configuration at the API Operation level. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. apiID is aPI identifier. Must be unique in +// the current API Management service instance. operationID is operation +// identifier within an API. Must be unique in the current API Management +// service instance. +func (client APIOperationsPolicyClient) Get(resourceGroupName string, serviceName string, apiID string, operationID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "operationID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsPolicyClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, serviceName, apiID, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsPolicyClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIOperationsPolicyClient) GetPreparer(resourceGroupName string, serviceName string, apiID string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policy", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationsPolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIOperationsPolicyClient) GetResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/apimanagement/apipolicy.go b/arm/apimanagement/apipolicy.go new file mode 100644 index 000000000000..a3b9aa1a60b5 --- /dev/null +++ b/arm/apimanagement/apipolicy.go @@ -0,0 +1,289 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "io" + "net/http" +) + +// APIPolicyClient is the composite Swagger for ApiManagement Client +type APIPolicyClient struct { + ManagementClient +} + +// NewAPIPolicyClient creates an instance of the APIPolicyClient client. +func NewAPIPolicyClient(subscriptionID string) APIPolicyClient { + return NewAPIPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIPolicyClientWithBaseURI creates an instance of the APIPolicyClient +// client. +func NewAPIPolicyClientWithBaseURI(baseURI string, subscriptionID string) APIPolicyClient { + return APIPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates policy configuration for the API. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. apiID is aPI identifier. Must be unique in +// the current API Management service instance. parameters is the policy +// contents to apply. parameters will be closed upon successful return. Callers +// should ensure closure when receiving an error.ifMatch is the entity state +// (Etag) version of the Api Policy to update. A value of "*" can be used for +// If-Match to unconditionally apply the operation. +func (client APIPolicyClient) CreateOrUpdate(resourceGroupName string, serviceName string, apiID string, parameters io.ReadCloser, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, apiID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIPolicyClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, apiID string, parameters io.ReadCloser, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policy", pathParameters), + autorest.WithFile(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete deletes the policy configuration at the Api. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. apiID is aPI identifier. Must be unique in +// the current API Management service instance. ifMatch is the entity state +// (Etag) version of the Api policy to update. A value of "*" can be used for +// If-Match to unconditionally apply the operation. +func (client APIPolicyClient) Delete(resourceGroupName string, serviceName string, apiID string, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIPolicyClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, serviceName, apiID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIPolicyClient) DeletePreparer(resourceGroupName string, serviceName string, apiID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policy", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the policy configuration at the API level. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. apiID is aPI identifier. Must be unique in +// the current API Management service instance. +func (client APIPolicyClient) Get(resourceGroupName string, serviceName string, apiID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIPolicyClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, serviceName, apiID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIPolicyClient) GetPreparer(resourceGroupName string, serviceName string, apiID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policy", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) GetResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/apimanagement/apiproducts.go b/arm/apimanagement/apiproducts.go index c6318aa041bd..e6ad33f397d9 100755 --- a/arm/apimanagement/apiproducts.go +++ b/arm/apimanagement/apiproducts.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// APIProductsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// APIProductsClient is the composite Swagger for ApiManagement Client type APIProductsClient struct { ManagementClient } @@ -43,7 +41,7 @@ func NewAPIProductsClientWithBaseURI(baseURI string, subscriptionID string) APIP return APIProductsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// ListByAPI lists all API associated products. +// ListByApis lists all API associated products. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. apiID is aPI identifier. Must be unique in @@ -53,7 +51,7 @@ func NewAPIProductsClientWithBaseURI(baseURI string, subscriptionID string) APIP // | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, // endswith | top is number of records to return. skip is number of records to // skip. -func (client APIProductsClient) ListByAPI(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (result ProductCollection, err error) { +func (client APIProductsClient) ListByApis(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (result ProductCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -69,30 +67,32 @@ func (client APIProductsClient) ListByAPI(resourceGroupName string, serviceName {TargetValue: skip, Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.APIProductsClient", "ListByAPI") + return result, validation.NewErrorWithValidationError(err, "apimanagement.APIProductsClient", "ListByApis") } - req, err := client.ListByAPIPreparer(resourceGroupName, serviceName, apiID, filter, top, skip) + req, err := client.ListByApisPreparer(resourceGroupName, serviceName, apiID, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByAPI", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByApis", nil, "Failure preparing request") + return } - resp, err := client.ListByAPISender(req) + resp, err := client.ListByApisSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByAPI", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByApis", resp, "Failure sending request") + return } - result, err = client.ListByAPIResponder(resp) + result, err = client.ListByApisResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByAPI", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByApis", resp, "Failure responding to request") } return } -// ListByAPIPreparer prepares the ListByAPI request. -func (client APIProductsClient) ListByAPIPreparer(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (*http.Request, error) { +// ListByApisPreparer prepares the ListByApis request. +func (client APIProductsClient) ListByApisPreparer(resourceGroupName string, serviceName string, apiID string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "apiId": autorest.Encode("path", apiID), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -100,7 +100,7 @@ func (client APIProductsClient) ListByAPIPreparer(resourceGroupName string, serv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -122,15 +122,15 @@ func (client APIProductsClient) ListByAPIPreparer(resourceGroupName string, serv return preparer.Prepare(&http.Request{}) } -// ListByAPISender sends the ListByAPI request. The method will close the +// ListByApisSender sends the ListByApis request. The method will close the // http.Response Body if it receives an error. -func (client APIProductsClient) ListByAPISender(req *http.Request) (*http.Response, error) { +func (client APIProductsClient) ListByApisSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByAPIResponder handles the response to the ListByAPI request. The method always +// ListByApisResponder handles the response to the ListByApis request. The method always // closes the http.Response Body. -func (client APIProductsClient) ListByAPIResponder(resp *http.Response) (result ProductCollection, err error) { +func (client APIProductsClient) ListByApisResponder(resp *http.Response) (result ProductCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -141,25 +141,25 @@ func (client APIProductsClient) ListByAPIResponder(resp *http.Response) (result return } -// ListByAPINextResults retrieves the next set of results, if any. -func (client APIProductsClient) ListByAPINextResults(lastResults ProductCollection) (result ProductCollection, err error) { +// ListByApisNextResults retrieves the next set of results, if any. +func (client APIProductsClient) ListByApisNextResults(lastResults ProductCollection) (result ProductCollection, err error) { req, err := lastResults.ProductCollectionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByAPI", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByApis", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByAPISender(req) + resp, err := client.ListByApisSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByAPI", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByApis", resp, "Failure sending next results request") } - result, err = client.ListByAPIResponder(resp) + result, err = client.ListByApisResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByAPI", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "apimanagement.APIProductsClient", "ListByApis", resp, "Failure responding to next results request") } return diff --git a/arm/apimanagement/apis.go b/arm/apimanagement/apis.go index 9b6e8e66d425..3a6c08d3c2c3 100755 --- a/arm/apimanagement/apis.go +++ b/arm/apimanagement/apis.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// ApisClient is the use these REST APIs for performing operations on entities -// like API, Product, and Subscription associated with your Azure API -// Management deployment. +// ApisClient is the composite Swagger for ApiManagement Client type ApisClient struct { ManagementClient } @@ -80,13 +78,15 @@ func (client ApisClient) CreateOrUpdate(resourceGroupName string, serviceName st req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, apiID, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -106,7 +106,7 @@ func (client ApisClient) CreateOrUpdatePreparer(resourceGroupName string, servic "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -165,13 +165,15 @@ func (client ApisClient) Delete(resourceGroupName string, serviceName string, ap req, err := client.DeletePreparer(resourceGroupName, serviceName, apiID, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -191,7 +193,7 @@ func (client ApisClient) DeletePreparer(resourceGroupName string, serviceName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -223,84 +225,6 @@ func (client ApisClient) DeleteResponder(resp *http.Response) (result autorest.R return } -// Export gets the details of the API specified by its identifier. -// -// resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. apiID is aPI identifier. Must be unique in -// the current API Management service instance. -func (client ApisClient) Export(resourceGroupName string, serviceName string, apiID string) (result APIExportResult, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: serviceName, - Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, - {TargetValue: apiID, - Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, - {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ApisClient", "Export") - } - - req, err := client.ExportPreparer(resourceGroupName, serviceName, apiID) - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Export", nil, "Failure preparing request") - } - - resp, err := client.ExportSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Export", resp, "Failure sending request") - } - - result, err = client.ExportResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Export", resp, "Failure responding to request") - } - - return -} - -// ExportPreparer prepares the Export request. -func (client ApisClient) ExportPreparer(resourceGroupName string, serviceName string, apiID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "apiId": autorest.Encode("path", apiID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "serviceName": autorest.Encode("path", serviceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-07-07" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ExportSender sends the Export request. The method will close the -// http.Response Body if it receives an error. -func (client ApisClient) ExportSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ExportResponder handles the response to the Export request. The method always -// closes the http.Response Body. -func (client ApisClient) ExportResponder(resp *http.Response) (result APIExportResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - // Get gets the details of the API specified by its identifier. // // resourceGroupName is the name of the resource group. serviceName is the name @@ -321,13 +245,15 @@ func (client ApisClient) Get(resourceGroupName string, serviceName string, apiID req, err := client.GetPreparer(resourceGroupName, serviceName, apiID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -347,7 +273,7 @@ func (client ApisClient) GetPreparer(resourceGroupName string, serviceName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -408,13 +334,15 @@ func (client ApisClient) ListByService(resourceGroupName string, serviceName str req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -433,7 +361,7 @@ func (client ApisClient) ListByServicePreparer(resourceGroupName string, service "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -502,11 +430,11 @@ func (client ApisClient) ListByServiceNextResults(lastResults APICollection) (re // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. apiID is aPI identifier. Must be unique in -// the current API Management service instance. parameters is patch parameters. -// ifMatch is eTag of the API entity. ETag should match the current entity -// state in the header response of the GET request or it should be * for -// unconditional update. -func (client ApisClient) Update(resourceGroupName string, serviceName string, apiID string, parameters PatchParameters, ifMatch string) (result autorest.Response, err error) { +// the current API Management service instance. parameters is aPI Update +// Contract parameters. ifMatch is eTag of the API entity. ETag should match +// the current entity state in the header response of the GET request or it +// should be * for unconditional update. +func (client ApisClient) Update(resourceGroupName string, serviceName string, apiID string, parameters APIUpdateContract, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -521,13 +449,15 @@ func (client ApisClient) Update(resourceGroupName string, serviceName string, ap req, err := client.UpdatePreparer(resourceGroupName, serviceName, apiID, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ApisClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -539,7 +469,7 @@ func (client ApisClient) Update(resourceGroupName string, serviceName string, ap } // UpdatePreparer prepares the Update request. -func (client ApisClient) UpdatePreparer(resourceGroupName string, serviceName string, apiID string, parameters PatchParameters, ifMatch string) (*http.Request, error) { +func (client ApisClient) UpdatePreparer(resourceGroupName string, serviceName string, apiID string, parameters APIUpdateContract, ifMatch string) (*http.Request, error) { pathParameters := map[string]interface{}{ "apiId": autorest.Encode("path", apiID), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -547,7 +477,7 @@ func (client ApisClient) UpdatePreparer(resourceGroupName string, serviceName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/authorizationservers.go b/arm/apimanagement/authorizationservers.go index 32051c488f15..e86fadd130cf 100755 --- a/arm/apimanagement/authorizationservers.go +++ b/arm/apimanagement/authorizationservers.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// AuthorizationServersClient is the use these REST APIs for performing -// operations on entities like API, Product, and Subscription associated with -// your Azure API Management deployment. +// AuthorizationServersClient is the composite Swagger for ApiManagement Client type AuthorizationServersClient struct { ManagementClient } @@ -73,13 +71,15 @@ func (client AuthorizationServersClient) CreateOrUpdate(resourceGroupName string req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, authsid, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -99,7 +99,7 @@ func (client AuthorizationServersClient) CreateOrUpdatePreparer(resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -144,19 +144,24 @@ func (client AuthorizationServersClient) Delete(resourceGroupName string, servic {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.AuthorizationServersClient", "Delete") } req, err := client.DeletePreparer(resourceGroupName, serviceName, authsid, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -176,7 +181,7 @@ func (client AuthorizationServersClient) DeletePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -228,13 +233,15 @@ func (client AuthorizationServersClient) Get(resourceGroupName string, serviceNa req, err := client.GetPreparer(resourceGroupName, serviceName, authsid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -254,7 +261,7 @@ func (client AuthorizationServersClient) GetPreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -315,13 +322,15 @@ func (client AuthorizationServersClient) ListByService(resourceGroupName string, req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -340,7 +349,7 @@ func (client AuthorizationServersClient) ListByServicePreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -419,19 +428,24 @@ func (client AuthorizationServersClient) Update(resourceGroupName string, servic {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.AuthorizationServersClient", "Update") } req, err := client.UpdatePreparer(resourceGroupName, serviceName, authsid, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -451,7 +465,7 @@ func (client AuthorizationServersClient) UpdatePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/backends.go b/arm/apimanagement/backends.go index e66fa3a9d4e2..807088d83c5b 100755 --- a/arm/apimanagement/backends.go +++ b/arm/apimanagement/backends.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// BackendsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// BackendsClient is the composite Swagger for ApiManagement Client type BackendsClient struct { ManagementClient } @@ -46,9 +44,9 @@ func NewBackendsClientWithBaseURI(baseURI string, subscriptionID string) Backend // CreateOrUpdate creates or Updates a backend. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. backendid is user identifier. Must be unique -// in the current API Management service instance. parameters is create -// parameters. +// of the API Management service. backendid is identifier of the Backend +// entity. Must be unique in the current API Management service instance. +// parameters is create parameters. func (client BackendsClient) CreateOrUpdate(resourceGroupName string, serviceName string, backendid string, parameters BackendContract) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, @@ -58,24 +56,21 @@ func (client BackendsClient) CreateOrUpdate(resourceGroupName string, serviceNam {TargetValue: backendid, Constraints: []validation.Constraint{{Target: "backendid", Name: validation.MaxLength, Rule: 255, Chain: nil}, {Target: "backendid", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "backendid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Host", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.Host", Name: validation.MaxLength, Rule: 255, Chain: nil}, - {Target: "parameters.Host", Name: validation.MinLength, Rule: 1, Chain: nil}, - }}}}}); err != nil { + {Target: "backendid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.BackendsClient", "CreateOrUpdate") } req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, backendid, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -95,7 +90,7 @@ func (client BackendsClient) CreateOrUpdatePreparer(resourceGroupName string, se "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -131,10 +126,10 @@ func (client BackendsClient) CreateOrUpdateResponder(resp *http.Response) (resul // Delete deletes the specified backend. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. backendid is user identifier. Must be unique -// in the current API Management service instance. ifMatch is the entity state -// (Etag) version of the backend to delete. A value of "*" can be used for -// If-Match to unconditionally apply the operation. +// of the API Management service. backendid is identifier of the Backend +// entity. Must be unique in the current API Management service instance. +// ifMatch is the entity state (Etag) version of the backend to delete. A value +// of "*" can be used for If-Match to unconditionally apply the operation. func (client BackendsClient) Delete(resourceGroupName string, serviceName string, backendid string, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, @@ -150,13 +145,15 @@ func (client BackendsClient) Delete(resourceGroupName string, serviceName string req, err := client.DeletePreparer(resourceGroupName, serviceName, backendid, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -176,7 +173,7 @@ func (client BackendsClient) DeletePreparer(resourceGroupName string, serviceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -211,8 +208,8 @@ func (client BackendsClient) DeleteResponder(resp *http.Response) (result autore // Get gets the details of the backend specified by its identifier. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. backendid is user identifier. Must be unique -// in the current API Management service instance. +// of the API Management service. backendid is identifier of the Backend +// entity. Must be unique in the current API Management service instance. func (client BackendsClient) Get(resourceGroupName string, serviceName string, backendid string) (result BackendResponse, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, @@ -228,13 +225,15 @@ func (client BackendsClient) Get(resourceGroupName string, serviceName string, b req, err := client.GetPreparer(resourceGroupName, serviceName, backendid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -254,7 +253,7 @@ func (client BackendsClient) GetPreparer(resourceGroupName string, serviceName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -315,13 +314,15 @@ func (client BackendsClient) ListByService(resourceGroupName string, serviceName req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -340,7 +341,7 @@ func (client BackendsClient) ListByServicePreparer(resourceGroupName string, ser "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -408,11 +409,11 @@ func (client BackendsClient) ListByServiceNextResults(lastResults BackendCollect // Update updates an existing backend. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. backendid is user identifier. Must be unique -// in the current API Management service instance. parameters is update -// parameters. ifMatch is the entity state (Etag) version of the backend to -// update. A value of "*" can be used for If-Match to unconditionally apply the -// operation. +// of the API Management service. backendid is identifier of the Backend +// entity. Must be unique in the current API Management service instance. +// parameters is update parameters. ifMatch is the entity state (Etag) version +// of the backend to update. A value of "*" can be used for If-Match to +// unconditionally apply the operation. func (client BackendsClient) Update(resourceGroupName string, serviceName string, backendid string, parameters BackendUpdateParameters, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, @@ -428,13 +429,15 @@ func (client BackendsClient) Update(resourceGroupName string, serviceName string req, err := client.UpdatePreparer(resourceGroupName, serviceName, backendid, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -454,7 +457,7 @@ func (client BackendsClient) UpdatePreparer(resourceGroupName string, serviceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/certificates.go b/arm/apimanagement/certificates.go index a83453fd0b28..0c4187e11194 100755 --- a/arm/apimanagement/certificates.go +++ b/arm/apimanagement/certificates.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// CertificatesClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// CertificatesClient is the composite Swagger for ApiManagement Client type CertificatesClient struct { ManagementClient } @@ -70,13 +68,15 @@ func (client CertificatesClient) CreateOrUpdate(resourceGroupName string, servic req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, certificateID, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -96,7 +96,7 @@ func (client CertificatesClient) CreateOrUpdatePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -137,27 +137,34 @@ func (client CertificatesClient) CreateOrUpdateResponder(resp *http.Response) (r // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. certificateID is identifier of the -// certificate. ifMatch is the entity state (Etag) version of the certificate -// to delete. A value of "*" can be used for If-Match to unconditionally apply -// the operation. +// certificate entity. Must be unique in the current API Management service +// instance. ifMatch is the entity state (Etag) version of the certificate to +// delete. A value of "*" can be used for If-Match to unconditionally apply the +// operation. func (client CertificatesClient) Delete(resourceGroupName string, serviceName string, certificateID string, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.CertificatesClient", "Delete") } req, err := client.DeletePreparer(resourceGroupName, serviceName, certificateID, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -177,7 +184,7 @@ func (client CertificatesClient) DeletePreparer(resourceGroupName string, servic "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -213,25 +220,32 @@ func (client CertificatesClient) DeleteResponder(resp *http.Response) (result au // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. certificateID is identifier of the -// certificate. +// certificate entity. Must be unique in the current API Management service +// instance. func (client CertificatesClient) Get(resourceGroupName string, serviceName string, certificateID string) (result CertificateContract, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.CertificatesClient", "Get") } req, err := client.GetPreparer(resourceGroupName, serviceName, certificateID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -251,7 +265,7 @@ func (client CertificatesClient) GetPreparer(resourceGroupName string, serviceNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -315,13 +329,15 @@ func (client CertificatesClient) ListByService(resourceGroupName string, service req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -340,7 +356,7 @@ func (client CertificatesClient) ListByServicePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/client.go b/arm/apimanagement/client.go index 728f48377a20..8abb7d74e842 100755 --- a/arm/apimanagement/client.go +++ b/arm/apimanagement/client.go @@ -1,8 +1,7 @@ // Package apimanagement implements the Azure ARM Apimanagement service API -// version 2016-07-07. +// version . // -// Use these REST APIs for performing operations on entities like API, Product, -// and Subscription associated with your Azure API Management deployment. +// Composite Swagger for ApiManagement Client package apimanagement // Copyright (c) Microsoft and contributors. All rights reserved. diff --git a/arm/apimanagement/groups.go b/arm/apimanagement/groups.go index c9da154422d3..6d0b62670960 100755 --- a/arm/apimanagement/groups.go +++ b/arm/apimanagement/groups.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// GroupsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// GroupsClient is the composite Swagger for ApiManagement Client type GroupsClient struct { ManagementClient } @@ -68,13 +66,15 @@ func (client GroupsClient) CreateOrUpdate(resourceGroupName string, serviceName req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, groupID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -94,7 +94,7 @@ func (client GroupsClient) CreateOrUpdatePreparer(resourceGroupName string, serv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -149,13 +149,15 @@ func (client GroupsClient) Delete(resourceGroupName string, serviceName string, req, err := client.DeletePreparer(resourceGroupName, serviceName, groupID, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -175,7 +177,7 @@ func (client GroupsClient) DeletePreparer(resourceGroupName string, serviceName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -228,13 +230,15 @@ func (client GroupsClient) Get(resourceGroupName string, serviceName string, gro req, err := client.GetPreparer(resourceGroupName, serviceName, groupID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -254,7 +258,7 @@ func (client GroupsClient) GetPreparer(resourceGroupName string, serviceName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -318,13 +322,15 @@ func (client GroupsClient) ListByService(resourceGroupName string, serviceName s req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -343,7 +349,7 @@ func (client GroupsClient) ListByServicePreparer(resourceGroupName string, servi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -431,13 +437,15 @@ func (client GroupsClient) Update(resourceGroupName string, serviceName string, req, err := client.UpdatePreparer(resourceGroupName, serviceName, groupID, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -457,7 +465,7 @@ func (client GroupsClient) UpdatePreparer(resourceGroupName string, serviceName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/groupusers.go b/arm/apimanagement/groupusers.go index 76b70c371356..3917da791b97 100755 --- a/arm/apimanagement/groupusers.go +++ b/arm/apimanagement/groupusers.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// GroupUsersClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// GroupUsersClient is the composite Swagger for ApiManagement Client type GroupUsersClient struct { ManagementClient } @@ -43,13 +41,13 @@ func NewGroupUsersClientWithBaseURI(baseURI string, subscriptionID string) Group return GroupUsersClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Add adds a user to the specified group. +// Create adds a user to the specified group. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. groupID is group identifier. Must be unique // in the current API Management service instance. uid is user identifier. Must // be unique in the current API Management service instance. -func (client GroupUsersClient) Add(resourceGroupName string, serviceName string, groupID string, uid string) (result ErrorBodyContract, err error) { +func (client GroupUsersClient) Create(resourceGroupName string, serviceName string, groupID string, uid string) (result ErrorBodyContract, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -63,30 +61,32 @@ func (client GroupUsersClient) Add(resourceGroupName string, serviceName string, Constraints: []validation.Constraint{{Target: "uid", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "uid", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "uid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.GroupUsersClient", "Add") + return result, validation.NewErrorWithValidationError(err, "apimanagement.GroupUsersClient", "Create") } - req, err := client.AddPreparer(resourceGroupName, serviceName, groupID, uid) + req, err := client.CreatePreparer(resourceGroupName, serviceName, groupID, uid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Add", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Create", nil, "Failure preparing request") + return } - resp, err := client.AddSender(req) + resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Add", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Create", resp, "Failure sending request") + return } - result, err = client.AddResponder(resp) + result, err = client.CreateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Add", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Create", resp, "Failure responding to request") } return } -// AddPreparer prepares the Add request. -func (client GroupUsersClient) AddPreparer(resourceGroupName string, serviceName string, groupID string, uid string) (*http.Request, error) { +// CreatePreparer prepares the Create request. +func (client GroupUsersClient) CreatePreparer(resourceGroupName string, serviceName string, groupID string, uid string) (*http.Request, error) { pathParameters := map[string]interface{}{ "groupId": autorest.Encode("path", groupID), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -95,7 +95,7 @@ func (client GroupUsersClient) AddPreparer(resourceGroupName string, serviceName "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -108,15 +108,15 @@ func (client GroupUsersClient) AddPreparer(resourceGroupName string, serviceName return preparer.Prepare(&http.Request{}) } -// AddSender sends the Add request. The method will close the +// CreateSender sends the Create request. The method will close the // http.Response Body if it receives an error. -func (client GroupUsersClient) AddSender(req *http.Request) (*http.Response, error) { +func (client GroupUsersClient) CreateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// AddResponder handles the response to the Add request. The method always +// CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client GroupUsersClient) AddResponder(resp *http.Response) (result ErrorBodyContract, err error) { +func (client GroupUsersClient) CreateResponder(resp *http.Response) (result ErrorBodyContract, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -127,30 +127,13 @@ func (client GroupUsersClient) AddResponder(resp *http.Response) (result ErrorBo return } -// ListByGroup lists a collection of the members of the group, specified by its -// identifier. +// Delete remove existing user from existing group. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. groupID is group identifier. Must be unique -// in the current API Management service instance. filter is | Field -// | Supported operators | Supported functions | -// |------------------|------------------------|-----------------------------------| -// | id | ge, le, eq, ne, gt, lt | substringof, contains, -// startswith, endswith | -// | firstName | ge, le, eq, ne, gt, lt | substringof, contains, -// startswith, endswith | -// | lastName | ge, le, eq, ne, gt, lt | substringof, contains, -// startswith, endswith | -// | email | ge, le, eq, ne, gt, lt | substringof, contains, -// startswith, endswith | -// | state | eq | N/A -// | -// | registrationDate | ge, le, eq, ne, gt, lt | N/A -// | -// | note | ge, le, eq, ne, gt, lt | substringof, contains, -// startswith, endswith | top is number of records to return. skip is number of -// records to skip. -func (client GroupUsersClient) ListByGroup(resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (result UserCollection, err error) { +// in the current API Management service instance. uid is user identifier. Must +// be unique in the current API Management service instance. +func (client GroupUsersClient) Delete(resourceGroupName string, serviceName string, groupID string, uid string) (result ErrorBodyContract, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -160,115 +143,100 @@ func (client GroupUsersClient) ListByGroup(resourceGroupName string, serviceName Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "groupID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.GroupUsersClient", "ListByGroup") + {TargetValue: uid, + Constraints: []validation.Constraint{{Target: "uid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "uid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "uid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.GroupUsersClient", "Delete") } - req, err := client.ListByGroupPreparer(resourceGroupName, serviceName, groupID, filter, top, skip) + req, err := client.DeletePreparer(resourceGroupName, serviceName, groupID, uid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Delete", nil, "Failure preparing request") + return } - resp, err := client.ListByGroupSender(req) + resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Delete", resp, "Failure sending request") + return } - result, err = client.ListByGroupResponder(resp) + result, err = client.DeleteResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroup", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Delete", resp, "Failure responding to request") } return } -// ListByGroupPreparer prepares the ListByGroup request. -func (client GroupUsersClient) ListByGroupPreparer(resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (*http.Request, error) { +// DeletePreparer prepares the Delete request. +func (client GroupUsersClient) DeletePreparer(resourceGroupName string, serviceName string, groupID string, uid string) (*http.Request, error) { pathParameters := map[string]interface{}{ "groupId": autorest.Encode("path", groupID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } preparer := autorest.CreatePreparer( - autorest.AsGet(), + autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{uid}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListByGroupSender sends the ListByGroup request. The method will close the +// DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. -func (client GroupUsersClient) ListByGroupSender(req *http.Request) (*http.Response, error) { +func (client GroupUsersClient) DeleteSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByGroupResponder handles the response to the ListByGroup request. The method always +// DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client GroupUsersClient) ListByGroupResponder(resp *http.Response) (result UserCollection, err error) { +func (client GroupUsersClient) DeleteResponder(resp *http.Response) (result ErrorBodyContract, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusMethodNotAllowed), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } -// ListByGroupNextResults retrieves the next set of results, if any. -func (client GroupUsersClient) ListByGroupNextResults(lastResults UserCollection) (result UserCollection, err error) { - req, err := lastResults.UserCollectionPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroup", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListByGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroup", resp, "Failure sending next results request") - } - - result, err = client.ListByGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroup", resp, "Failure responding to next results request") - } - - return -} - -// Remove remove existing user from existing group. +// ListByGroups lists a collection of the members of the group, specified by +// its identifier. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. groupID is group identifier. Must be unique -// in the current API Management service instance. uid is user identifier. Must -// be unique in the current API Management service instance. -func (client GroupUsersClient) Remove(resourceGroupName string, serviceName string, groupID string, uid string) (result ErrorBodyContract, err error) { +// in the current API Management service instance. filter is | Field +// | Supported operators | Supported functions | +// |------------------|------------------------|-----------------------------------| +// | id | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith | +// | firstName | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith | +// | lastName | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith | +// | email | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith | +// | state | eq | N/A +// | +// | registrationDate | ge, le, eq, ne, gt, lt | N/A +// | +// | note | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith | top is number of records to return. skip is number of +// records to skip. +func (client GroupUsersClient) ListByGroups(resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (result UserCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -278,70 +246,106 @@ func (client GroupUsersClient) Remove(resourceGroupName string, serviceName stri Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "groupID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, - {TargetValue: uid, - Constraints: []validation.Constraint{{Target: "uid", Name: validation.MaxLength, Rule: 256, Chain: nil}, - {Target: "uid", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "uid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.GroupUsersClient", "Remove") + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.GroupUsersClient", "ListByGroups") } - req, err := client.RemovePreparer(resourceGroupName, serviceName, groupID, uid) + req, err := client.ListByGroupsPreparer(resourceGroupName, serviceName, groupID, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Remove", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroups", nil, "Failure preparing request") + return } - resp, err := client.RemoveSender(req) + resp, err := client.ListByGroupsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Remove", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroups", resp, "Failure sending request") + return } - result, err = client.RemoveResponder(resp) + result, err = client.ListByGroupsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "Remove", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroups", resp, "Failure responding to request") } return } -// RemovePreparer prepares the Remove request. -func (client GroupUsersClient) RemovePreparer(resourceGroupName string, serviceName string, groupID string, uid string) (*http.Request, error) { +// ListByGroupsPreparer prepares the ListByGroups request. +func (client GroupUsersClient) ListByGroupsPreparer(resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "groupId": autorest.Encode("path", groupID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } preparer := autorest.CreatePreparer( - autorest.AsDelete(), + autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{uid}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// RemoveSender sends the Remove request. The method will close the +// ListByGroupsSender sends the ListByGroups request. The method will close the // http.Response Body if it receives an error. -func (client GroupUsersClient) RemoveSender(req *http.Request) (*http.Response, error) { +func (client GroupUsersClient) ListByGroupsSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// RemoveResponder handles the response to the Remove request. The method always +// ListByGroupsResponder handles the response to the ListByGroups request. The method always // closes the http.Response Body. -func (client GroupUsersClient) RemoveResponder(resp *http.Response) (result ErrorBodyContract, err error) { +func (client GroupUsersClient) ListByGroupsResponder(resp *http.Response) (result UserCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusMethodNotAllowed), + azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } + +// ListByGroupsNextResults retrieves the next set of results, if any. +func (client GroupUsersClient) ListByGroupsNextResults(lastResults UserCollection) (result UserCollection, err error) { + req, err := lastResults.UserCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroups", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByGroupsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroups", resp, "Failure sending next results request") + } + + result, err = client.ListByGroupsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUsersClient", "ListByGroups", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/apimanagement/identityproviders.go b/arm/apimanagement/identityproviders.go index b5e2baf2d581..9bc0cc0545ac 100755 --- a/arm/apimanagement/identityproviders.go +++ b/arm/apimanagement/identityproviders.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// IdentityProvidersClient is the use these REST APIs for performing operations -// on entities like API, Product, and Subscription associated with your Azure -// API Management deployment. +// IdentityProvidersClient is the composite Swagger for ApiManagement Client type IdentityProvidersClient struct { ManagementClient } @@ -67,13 +65,15 @@ func (client IdentityProvidersClient) CreateOrUpdate(resourceGroupName string, s req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, identityProviderName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -93,7 +93,7 @@ func (client IdentityProvidersClient) CreateOrUpdatePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -144,13 +144,15 @@ func (client IdentityProvidersClient) Delete(resourceGroupName string, serviceNa req, err := client.DeletePreparer(resourceGroupName, serviceName, identityProviderName, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -170,7 +172,7 @@ func (client IdentityProvidersClient) DeletePreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -219,13 +221,15 @@ func (client IdentityProvidersClient) Get(resourceGroupName string, serviceName req, err := client.GetPreparer(resourceGroupName, serviceName, identityProviderName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -245,7 +249,7 @@ func (client IdentityProvidersClient) GetPreparer(resourceGroupName string, serv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -293,13 +297,15 @@ func (client IdentityProvidersClient) ListByService(resourceGroupName string, se req, err := client.ListByServicePreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -318,7 +324,7 @@ func (client IdentityProvidersClient) ListByServicePreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -369,13 +375,15 @@ func (client IdentityProvidersClient) Update(resourceGroupName string, serviceNa req, err := client.UpdatePreparer(resourceGroupName, serviceName, identityProviderName, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProvidersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -395,7 +403,7 @@ func (client IdentityProvidersClient) UpdatePreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/loggers.go b/arm/apimanagement/loggers.go index 4292f235dfde..8a2506b79015 100755 --- a/arm/apimanagement/loggers.go +++ b/arm/apimanagement/loggers.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// LoggersClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// LoggersClient is the composite Swagger for ApiManagement Client type LoggersClient struct { ManagementClient } @@ -45,8 +43,8 @@ func NewLoggersClientWithBaseURI(baseURI string, subscriptionID string) LoggersC // CreateOrUpdate creates or Updates a logger. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. loggerid is identifier of the logger. -// parameters is create parameters. +// of the API Management service. loggerid is logger identifier. Must be unique +// in the API Management service instance. parameters is create parameters. func (client LoggersClient) CreateOrUpdate(resourceGroupName string, serviceName string, loggerid string, parameters LoggerCreateParameters) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, @@ -64,13 +62,15 @@ func (client LoggersClient) CreateOrUpdate(resourceGroupName string, serviceName req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, loggerid, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -90,7 +90,7 @@ func (client LoggersClient) CreateOrUpdatePreparer(resourceGroupName string, ser "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -126,27 +126,33 @@ func (client LoggersClient) CreateOrUpdateResponder(resp *http.Response) (result // Delete deletes the specified logger. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. loggerid is identifier of the logger. ifMatch -// is the entity state (Etag) version of the logger to delete. A value of "*" -// can be used for If-Match to unconditionally apply the operation. +// of the API Management service. loggerid is logger identifier. Must be unique +// in the API Management service instance. ifMatch is the entity state (Etag) +// version of the logger to delete. A value of "*" can be used for If-Match to +// unconditionally apply the operation. func (client LoggersClient) Delete(resourceGroupName string, serviceName string, loggerid string, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerid, + Constraints: []validation.Constraint{{Target: "loggerid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.LoggersClient", "Delete") } req, err := client.DeletePreparer(resourceGroupName, serviceName, loggerid, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -166,7 +172,7 @@ func (client LoggersClient) DeletePreparer(resourceGroupName string, serviceName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -201,25 +207,31 @@ func (client LoggersClient) DeleteResponder(resp *http.Response) (result autores // Get gets the details of the logger specified by its identifier. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. loggerid is identifier of the logger. +// of the API Management service. loggerid is logger identifier. Must be unique +// in the API Management service instance. func (client LoggersClient) Get(resourceGroupName string, serviceName string, loggerid string) (result LoggerResponse, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerid, + Constraints: []validation.Constraint{{Target: "loggerid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.LoggersClient", "Get") } req, err := client.GetPreparer(resourceGroupName, serviceName, loggerid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -239,7 +251,7 @@ func (client LoggersClient) GetPreparer(resourceGroupName string, serviceName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -299,13 +311,15 @@ func (client LoggersClient) ListByService(resourceGroupName string, serviceName req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -324,7 +338,7 @@ func (client LoggersClient) ListByServicePreparer(resourceGroupName string, serv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -392,28 +406,33 @@ func (client LoggersClient) ListByServiceNextResults(lastResults LoggerCollectio // Update updates an existing logger. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. loggerid is identifier of the logger. -// parameters is update parameters. ifMatch is the entity state (Etag) version -// of the logger to update. A value of "*" can be used for If-Match to -// unconditionally apply the operation. +// of the API Management service. loggerid is logger identifier. Must be unique +// in the API Management service instance. parameters is update parameters. +// ifMatch is the entity state (Etag) version of the logger to update. A value +// of "*" can be used for If-Match to unconditionally apply the operation. func (client LoggersClient) Update(resourceGroupName string, serviceName string, loggerid string, parameters LoggerUpdateParameters, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerid, + Constraints: []validation.Constraint{{Target: "loggerid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.LoggersClient", "Update") } req, err := client.UpdatePreparer(resourceGroupName, serviceName, loggerid, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.LoggersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -433,7 +452,7 @@ func (client LoggersClient) UpdatePreparer(resourceGroupName string, serviceName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/models.go b/arm/apimanagement/models.go index c90cb95093d1..f2fd0fc9d46d 100755 --- a/arm/apimanagement/models.go +++ b/arm/apimanagement/models.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" + "io" "net/http" ) @@ -61,6 +62,18 @@ const ( Succeeded AsyncOperationState = "Succeeded" ) +// BackendProtocol enumerates the values for backend protocol. +type BackendProtocol string + +const ( + // BackendProtocolHTTP specifies the backend protocol http state for + // backend protocol. + BackendProtocolHTTP BackendProtocol = "http" + // BackendProtocolSoap specifies the backend protocol soap state for + // backend protocol. + BackendProtocolSoap BackendProtocol = "soap" +) + // BearerTokenSendingMethodsContract enumerates the values for bearer token // sending methods contract. type BearerTokenSendingMethodsContract string @@ -86,6 +99,19 @@ const ( Body ClientAuthenticationMethodContract = "Body" ) +// ConnectivityStatusType enumerates the values for connectivity status type. +type ConnectivityStatusType string + +const ( + // Failure specifies the failure state for connectivity status type. + Failure ConnectivityStatusType = "failure" + // Initializing specifies the initializing state for connectivity status + // type. + Initializing ConnectivityStatusType = "initializing" + // Success specifies the success state for connectivity status type. + Success ConnectivityStatusType = "success" +) + // GrantTypesContract enumerates the values for grant types contract. type GrantTypesContract string @@ -115,6 +141,20 @@ const ( System GroupTypeContract = "System" ) +// HostnameType enumerates the values for hostname type. +type HostnameType string + +const ( + // Management specifies the management state for hostname type. + Management HostnameType = "Management" + // Portal specifies the portal state for hostname type. + Portal HostnameType = "Portal" + // Proxy specifies the proxy state for hostname type. + Proxy HostnameType = "Proxy" + // Scm specifies the scm state for hostname type. + Scm HostnameType = "Scm" +) + // HTTPStatusCode enumerates the values for http status code. type HTTPStatusCode string @@ -140,6 +180,8 @@ type IdentityProviderNameType string const ( // Aad specifies the aad state for identity provider name type. Aad IdentityProviderNameType = "aad" + // AadB2C specifies the aad b2c state for identity provider name type. + AadB2C IdentityProviderNameType = "aadB2C" // Facebook specifies the facebook state for identity provider name type. Facebook IdentityProviderNameType = "facebook" // Google specifies the google state for identity provider name type. @@ -172,35 +214,38 @@ const ( TRACE MethodContract = "TRACE" ) -// OperationStatus enumerates the values for operation status. -type OperationStatus string +// NameAvailabilityReason enumerates the values for name availability reason. +type NameAvailabilityReason string const ( - // OperationStatusFailed specifies the operation status failed state for - // operation status. - OperationStatusFailed OperationStatus = "Failed" - // OperationStatusInProgress specifies the operation status in progress - // state for operation status. - OperationStatusInProgress OperationStatus = "InProgress" - // OperationStatusSucceeded specifies the operation status succeeded state - // for operation status. - OperationStatusSucceeded OperationStatus = "Succeeded" + // AlreadyExists specifies the already exists state for name availability + // reason. + AlreadyExists NameAvailabilityReason = "AlreadyExists" + // Invalid specifies the invalid state for name availability reason. + Invalid NameAvailabilityReason = "Invalid" + // Valid specifies the valid state for name availability reason. + Valid NameAvailabilityReason = "Valid" ) // PolicyScopeContract enumerates the values for policy scope contract. type PolicyScopeContract string const ( - // All specifies the all state for policy scope contract. - All PolicyScopeContract = "All" - // API specifies the api state for policy scope contract. - API PolicyScopeContract = "Api" - // Operation specifies the operation state for policy scope contract. - Operation PolicyScopeContract = "Operation" - // Product specifies the product state for policy scope contract. - Product PolicyScopeContract = "Product" - // Tenant specifies the tenant state for policy scope contract. - Tenant PolicyScopeContract = "Tenant" + // PolicyScopeContractAll specifies the policy scope contract all state for + // policy scope contract. + PolicyScopeContractAll PolicyScopeContract = "All" + // PolicyScopeContractAPI specifies the policy scope contract api state for + // policy scope contract. + PolicyScopeContractAPI PolicyScopeContract = "Api" + // PolicyScopeContractOperation specifies the policy scope contract + // operation state for policy scope contract. + PolicyScopeContractOperation PolicyScopeContract = "Operation" + // PolicyScopeContractProduct specifies the policy scope contract product + // state for policy scope contract. + PolicyScopeContractProduct PolicyScopeContract = "Product" + // PolicyScopeContractTenant specifies the policy scope contract tenant + // state for policy scope contract. + PolicyScopeContractTenant PolicyScopeContract = "Tenant" ) // ProductStateContract enumerates the values for product state contract. @@ -235,6 +280,18 @@ const ( ByUser ReportsAggregation = "byUser" ) +// SkuType enumerates the values for sku type. +type SkuType string + +const ( + // Developer specifies the developer state for sku type. + Developer SkuType = "Developer" + // Premium specifies the premium state for sku type. + Premium SkuType = "Premium" + // Standard specifies the standard state for sku type. + Standard SkuType = "Standard" +) + // SubscriptionStateContract enumerates the values for subscription state // contract. type SubscriptionStateContract string @@ -266,6 +323,21 @@ const ( UserStateContractBlocked UserStateContract = "Blocked" ) +// VirtualNetworkType enumerates the values for virtual network type. +type VirtualNetworkType string + +const ( + // VirtualNetworkTypeExternal specifies the virtual network type external + // state for virtual network type. + VirtualNetworkTypeExternal VirtualNetworkType = "External" + // VirtualNetworkTypeInternal specifies the virtual network type internal + // state for virtual network type. + VirtualNetworkTypeInternal VirtualNetworkType = "Internal" + // VirtualNetworkTypeNone specifies the virtual network type none state for + // virtual network type. + VirtualNetworkTypeNone VirtualNetworkType = "None" +) + // AccessInformationContract is tenant access information contract of the API // Management service. type AccessInformationContract struct { @@ -282,6 +354,16 @@ type AccessInformationUpdateParameters struct { Enabled *bool `json:"enabled,omitempty"` } +// AdditionalRegion is description of an additional API Management resource +// location. +type AdditionalRegion struct { + Location *string `json:"location,omitempty"` + SkuType SkuType `json:"skuType,omitempty"` + SkuUnitCount *int32 `json:"skuUnitCount,omitempty"` + StaticIPs *[]string `json:"staticIPs,omitempty"` + Vpnconfiguration *VirtualNetworkConfiguration `json:"vpnconfiguration,omitempty"` +} + // APICollection is paged Api list representation. type APICollection struct { autorest.Response `json:"-"` @@ -305,12 +387,20 @@ func (client APICollection) APICollectionPreparer() (*http.Request, error) { // APIContract is aPI details. type APIContract struct { autorest.Response `json:"-"` + Description *string `json:"description,omitempty"` + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + Type APITypeContract `json:"type,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` - Description *string `json:"description,omitempty"` ServiceURL *string `json:"serviceUrl,omitempty"` Path *string `json:"path,omitempty"` Protocols *[]APIProtocolContract `json:"protocols,omitempty"` +} + +// APIEntityBaseContract is aPI base contract details. +type APIEntityBaseContract struct { + Description *string `json:"description,omitempty"` AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` Type APITypeContract `json:"type,omitempty"` @@ -324,6 +414,19 @@ type APIExportResult struct { RequestID *string `json:"requestId,omitempty"` } +// APIUpdateContract is aPI Update Contract details. +type APIUpdateContract struct { + Description *string `json:"description,omitempty"` + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + Type APITypeContract `json:"type,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + ServiceURL *string `json:"serviceUrl,omitempty"` + Path *string `json:"path,omitempty"` + Protocols *[]APIProtocolContract `json:"protocols,omitempty"` +} + // AuthenticationSettingsContract is aPI Authentication Settings. type AuthenticationSettingsContract struct { OAuth2 *OAuth2AuthenticationSettingsContract `json:"oAuth2,omitempty"` @@ -350,6 +453,26 @@ func (client AuthorizationServerCollection) AuthorizationServerCollectionPrepare autorest.WithBaseURL(to.String(client.NextLink))) } +// BackendAuthorizationHeaderCredentials is authorization header information. +type BackendAuthorizationHeaderCredentials struct { + Scheme *string `json:"scheme,omitempty"` + Parameter *string `json:"parameter,omitempty"` +} + +// BackendBaseParameters is backend entity base Parameter set. +type BackendBaseParameters struct { + Certificate *[]string `json:"certificate,omitempty"` + Query *map[string][]string `json:"query,omitempty"` + Header *map[string][]string `json:"header,omitempty"` + URL *string `json:"url,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + Title *string `json:"title,omitempty"` + Description *string `json:"description,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + *BackendProperties `json:"properties,omitempty"` +} + // BackendCollection is paged Backend list representation. type BackendCollection struct { autorest.Response `json:"-"` @@ -372,25 +495,77 @@ func (client BackendCollection) BackendCollectionPreparer() (*http.Request, erro // BackendContract is parameters supplied to the Create Backend operation. type BackendContract struct { - Host *string `json:"host,omitempty"` - SkipCertificateChainValidation *bool `json:"skipCertificateChainValidation,omitempty"` + Certificate *[]string `json:"certificate,omitempty"` + Query *map[string][]string `json:"query,omitempty"` + Header *map[string][]string `json:"header,omitempty"` + URL *string `json:"url,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + Title *string `json:"title,omitempty"` + Description *string `json:"description,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + *BackendProperties `json:"properties,omitempty"` + ID *string `json:"id,omitempty"` + Protocol BackendProtocol `json:"protocol,omitempty"` +} + +// BackendCredentialsContract is details of the Credentials used to connect to +// Backend. +type BackendCredentialsContract struct { + Scheme *string `json:"scheme,omitempty"` + Parameter *string `json:"parameter,omitempty"` + Certificate *[]string `json:"certificate,omitempty"` + Query *map[string][]string `json:"query,omitempty"` + Header *map[string][]string `json:"header,omitempty"` +} + +// BackendProperties is properties specific to a Backend. +type BackendProperties struct { + SkipCertificateChainValidation *bool `json:"skipCertificateChainValidation,omitempty"` + SkipCertificateNameValidation *bool `json:"skipCertificateNameValidation,omitempty"` +} + +// BackendProxyContract is details of the Backend WebProxy Server to use in the +// Request to Backend. +type BackendProxyContract struct { + URL *string `json:"url,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` } // BackendResponse is the Backend entity in API Management represents a backend // service that is configured to skip certification chain validation when using // a self-signed certificate to test mutual certificate authentication. type BackendResponse struct { - autorest.Response `json:"-"` - Host *string `json:"host,omitempty"` - SkipCertificateChainValidation *bool `json:"skipCertificateChainValidation,omitempty"` - ID *string `json:"id,omitempty"` + autorest.Response `json:"-"` + Certificate *[]string `json:"certificate,omitempty"` + Query *map[string][]string `json:"query,omitempty"` + Header *map[string][]string `json:"header,omitempty"` + URL *string `json:"url,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + Title *string `json:"title,omitempty"` + Description *string `json:"description,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + *BackendProperties `json:"properties,omitempty"` + ID *string `json:"id,omitempty"` + Protocol BackendProtocol `json:"protocol,omitempty"` } // BackendUpdateParameters is parameters supplied to the Update Backend // operation. type BackendUpdateParameters struct { - Host *string `json:"host,omitempty"` - SkipCertificateChainValidation *bool `json:"skipCertificateChainValidation,omitempty"` + Certificate *[]string `json:"certificate,omitempty"` + Query *map[string][]string `json:"query,omitempty"` + Header *map[string][]string `json:"header,omitempty"` + URL *string `json:"url,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + Title *string `json:"title,omitempty"` + Description *string `json:"description,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + *BackendProperties `json:"properties,omitempty"` + Protocol BackendProtocol `json:"protocol,omitempty"` } // CertificateCollection is paged Certificates list representation. @@ -429,6 +604,23 @@ type CertificateCreateOrUpdateParameters struct { Password *string `json:"password,omitempty"` } +// CertificateInformation is sSL certificate information. +type CertificateInformation struct { + autorest.Response `json:"-"` + Expiry *date.Time `json:"expiry,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Subject *string `json:"subject,omitempty"` +} + +// ConnectivityStatusContract is details about connectivity to a resource. +type ConnectivityStatusContract struct { + Name *string `json:"name,omitempty"` + Status ConnectivityStatusType `json:"status,omitempty"` + Error *string `json:"error,omitempty"` + LastUpdated *date.Time `json:"lastUpdated,omitempty"` + LastStatusChange *date.Time `json:"lastStatusChange,omitempty"` +} + // DeployConfigurationParameters is parameters supplied to the Deploy // Configuration operation. type DeployConfigurationParameters struct { @@ -451,6 +643,12 @@ type ErrorFieldContract struct { Target *string `json:"target,omitempty"` } +// ErrorResponse is error Response. +type ErrorResponse struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + // GenerateSsoURLResult is generate SSO Url operations response details. type GenerateSsoURLResult struct { autorest.Response `json:"-"` @@ -504,6 +702,13 @@ type GroupUpdateParameters struct { ExternalID *string `json:"externalId,omitempty"` } +// HostnameConfiguration is custom hostname configuration. +type HostnameConfiguration struct { + Type HostnameType `json:"type,omitempty"` + Hostname *string `json:"hostname,omitempty"` + Certificate *CertificateInformation `json:"certificate,omitempty"` +} + // IdentityProviderContract is the external Identity Providers like Facebook, // Google, Microsoft, Twitter or Azure Active Directory which can be used to // enable access to the API Management service developer portal for all users. @@ -530,18 +735,6 @@ type IdentityProviderUpdateParameters struct { AllowedTenants *[]string `json:"allowedTenants,omitempty"` } -// ListPolicySnippetContract is -type ListPolicySnippetContract struct { - autorest.Response `json:"-"` - Value *[]PolicySnippetContract `json:"value,omitempty"` -} - -// ListUserIdentityContract is -type ListUserIdentityContract struct { - autorest.Response `json:"-"` - Value *[]UserIdentityContract `json:"value,omitempty"` -} - // LoggerCollection is paged Logger list representation. type LoggerCollection struct { autorest.Response `json:"-"` @@ -592,6 +785,13 @@ type LoggerUpdateParameters struct { IsBuffered *bool `json:"isBuffered,omitempty"` } +// NetworkStatusContract is network Status details. +type NetworkStatusContract struct { + autorest.Response `json:"-"` + DNSServers *[]string `json:"dnsServers,omitempty"` + ConnectivityStatus *[]ConnectivityStatusContract `json:"connectivityStatus,omitempty"` +} + // OAuth2AuthenticationSettingsContract is aPI OAuth2 Authentication settings // details. type OAuth2AuthenticationSettingsContract struct { @@ -695,6 +895,20 @@ type OpenidConnectProviderUpdateContract struct { ClientSecret *string `json:"clientSecret,omitempty"` } +// Operation is rEST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is the object that describes the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Operation *string `json:"operation,omitempty"` + Resource *string `json:"resource,omitempty"` + Description *string `json:"description,omitempty"` +} + // OperationCollection is paged Operation list representation. type OperationCollection struct { autorest.Response `json:"-"` @@ -718,16 +932,45 @@ func (client OperationCollection) OperationCollectionPreparer() (*http.Request, // OperationContract is api Operation details. type OperationContract struct { autorest.Response `json:"-"` + TemplateParameters *[]ParameterContract `json:"templateParameters,omitempty"` + Description *string `json:"description,omitempty"` + Request *RequestContract `json:"request,omitempty"` + Responses *[]ResultContract `json:"responses,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Method *string `json:"method,omitempty"` URLTemplate *string `json:"urlTemplate,omitempty"` +} + +// OperationEntityBaseContract is api Operation Entity Base Contract details. +type OperationEntityBaseContract struct { TemplateParameters *[]ParameterContract `json:"templateParameters,omitempty"` Description *string `json:"description,omitempty"` Request *RequestContract `json:"request,omitempty"` Responses *[]ResultContract `json:"responses,omitempty"` } +// OperationListResult is result of the request to list REST API operations. It +// contains a list of operations and a URL nextLink to get the next set of +// results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + // OperationResultContract is operation Result. type OperationResultContract struct { autorest.Response `json:"-"` @@ -739,6 +982,18 @@ type OperationResultContract struct { Error *ErrorBodyContract `json:"error,omitempty"` } +// OperationUpdateContract is api Operation Update Contract details. +type OperationUpdateContract struct { + TemplateParameters *[]ParameterContract `json:"templateParameters,omitempty"` + Description *string `json:"description,omitempty"` + Request *RequestContract `json:"request,omitempty"` + Responses *[]ResultContract `json:"responses,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Method *string `json:"method,omitempty"` + URLTemplate *string `json:"urlTemplate,omitempty"` +} + // ParameterContract is operation parameters details. type ParameterContract struct { Name *string `json:"name,omitempty"` @@ -749,11 +1004,6 @@ type ParameterContract struct { Values *[]string `json:"values,omitempty"` } -// PatchParameters is parameters supplied to the Patch operations. -type PatchParameters struct { - RawJSON *map[string]interface{} `json:"RawJson,omitempty"` -} - // PolicySnippetContract is policy snippet. type PolicySnippetContract struct { Name *string `json:"name,omitempty"` @@ -762,6 +1012,13 @@ type PolicySnippetContract struct { Scope PolicyScopeContract `json:"scope,omitempty"` } +// PolicySnippetsCollection is the response of the list policy snippets +// operation. +type PolicySnippetsCollection struct { + autorest.Response `json:"-"` + Value *[]PolicySnippetContract `json:"value,omitempty"` +} + // ProductCollection is paged Products list representation. type ProductCollection struct { autorest.Response `json:"-"` @@ -880,6 +1137,12 @@ type QuotaCounterValueContract struct { KbTransferred *float64 `json:"kbTransferred,omitempty"` } +// ReadCloser is +type ReadCloser struct { + autorest.Response `json:"-"` + Value *io.ReadCloser `json:"value,omitempty"` +} + // RegionContract is region profile. type RegionContract struct { Name *string `json:"name,omitempty"` @@ -956,6 +1219,15 @@ type RequestContract struct { Representations *[]RepresentationContract `json:"representations,omitempty"` } +// Resource is the Resource definition. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + // ResultContract is operation response details. type ResultContract struct { StatusCode *int32 `json:"statusCode,omitempty"` @@ -970,7 +1242,132 @@ type SaveConfigurationParameter struct { Force *bool `json:"force,omitempty"` } -// SubscriptionCollection is paged Subsctions list representation. +// ServiceBackupRestoreParameters is parameters supplied to the Backup/Restore +// of an API Management service operation. +type ServiceBackupRestoreParameters struct { + StorageAccount *string `json:"storageAccount,omitempty"` + AccessKey *string `json:"accessKey,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + BackupName *string `json:"backupName,omitempty"` +} + +// ServiceCheckNameAvailabilityParameters is parameters supplied to the +// CheckNameAvailability operation. +type ServiceCheckNameAvailabilityParameters struct { + Name *string `json:"name,omitempty"` +} + +// ServiceGetSsoTokenResult is the response of the GetSsoToken operation. +type ServiceGetSsoTokenResult struct { + autorest.Response `json:"-"` + RedirectURI *string `json:"redirect_uri,omitempty"` +} + +// ServiceListResult is the response of the List API Management services +// operation. +type ServiceListResult struct { + autorest.Response `json:"-"` + Value *[]ServiceResource `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ServiceListResult) ServiceListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ServiceManageDeploymentsParameters is parameters supplied to the +// ManageDeployments operation. +type ServiceManageDeploymentsParameters struct { + Location *string `json:"location,omitempty"` + SkuType SkuType `json:"skuType,omitempty"` + SkuUnitCount *int32 `json:"skuUnitCount,omitempty"` + AdditionalLocations *[]AdditionalRegion `json:"additionalLocations,omitempty"` + VpnConfiguration *VirtualNetworkConfiguration `json:"vpnConfiguration,omitempty"` + VpnType VirtualNetworkType `json:"vpnType,omitempty"` +} + +// ServiceNameAvailabilityResult is response of the CheckNameAvailability +// operation. +type ServiceNameAvailabilityResult struct { + autorest.Response `json:"-"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Message *string `json:"message,omitempty"` + Reason NameAvailabilityReason `json:"reason,omitempty"` +} + +// ServiceProperties is properties of an API Management service resource +// description. +type ServiceProperties struct { + PublisherEmail *string `json:"publisherEmail,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + TargetProvisioningState *string `json:"targetProvisioningState,omitempty"` + CreatedAtUtc *date.Time `json:"createdAtUtc,omitempty"` + RuntimeURL *string `json:"runtimeUrl,omitempty"` + PortalURL *string `json:"portalUrl,omitempty"` + ManagementAPIURL *string `json:"managementApiUrl,omitempty"` + ScmURL *string `json:"scmUrl,omitempty"` + AddresserEmail *string `json:"addresserEmail,omitempty"` + HostnameConfigurations *[]HostnameConfiguration `json:"hostnameConfigurations,omitempty"` + StaticIPs *[]string `json:"staticIPs,omitempty"` + Vpnconfiguration *VirtualNetworkConfiguration `json:"vpnconfiguration,omitempty"` + AdditionalLocations *[]AdditionalRegion `json:"additionalLocations,omitempty"` + CustomProperties *map[string]*string `json:"customProperties,omitempty"` + VpnType VirtualNetworkType `json:"vpnType,omitempty"` +} + +// ServiceResource is a single API Management service resource in List or Get +// response. +type ServiceResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ServiceProperties `json:"properties,omitempty"` + Sku *ServiceSkuProperties `json:"sku,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// ServiceSkuProperties is aPI Management service resource SKU properties. +type ServiceSkuProperties struct { + Name SkuType `json:"name,omitempty"` + Capacity *int32 `json:"capacity,omitempty"` +} + +// ServiceUpdateHostnameParameters is parameters supplied to the UpdateHostname +// operation. +type ServiceUpdateHostnameParameters struct { + Update *[]HostnameConfiguration `json:"update,omitempty"` + Delete *[]HostnameType `json:"delete,omitempty"` +} + +// ServiceUpdateParameters is parameters supplied to the Update API Management +// service operation. +type ServiceUpdateParameters struct { + *ServiceProperties `json:"properties,omitempty"` + Sku *ServiceSkuProperties `json:"sku,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ServiceUploadCertificateParameters is parameters supplied to the Upload SSL +// certificate for an API Management service operation. +type ServiceUploadCertificateParameters struct { + Type HostnameType `json:"type,omitempty"` + Certificate *string `json:"certificate,omitempty"` + CertificatePassword *string `json:"certificate_password,omitempty"` +} + +// SubscriptionCollection is paged Subscriptions list representation. type SubscriptionCollection struct { autorest.Response `json:"-"` Value *[]SubscriptionContract `json:"value,omitempty"` @@ -1052,16 +1449,6 @@ type TenantConfigurationSyncStateContract struct { ConfigurationChangeDate *date.Time `json:"configurationChangeDate,omitempty"` } -// TenantLongRunningOperationResult is a standard service response for long -// running tenant operations. -type TenantLongRunningOperationResult struct { - OperationStatusLink *string `json:"operationStatusLink,omitempty"` - RetryAfter *int32 `json:"retryAfter,omitempty"` - Status OperationStatus `json:"status,omitempty"` - StatusCode HTTPStatusCode `json:"statusCode,omitempty"` - RequestID *string `json:"requestId,omitempty"` -} - // TokenBodyParameterContract is oAuth acquire token request body parameter // (www-url-form-encoded). type TokenBodyParameterContract struct { @@ -1112,6 +1499,12 @@ type UserCreateParameters struct { Note *string `json:"note,omitempty"` } +// UserIdentityCollection is list of Users Identity list representation. +type UserIdentityCollection struct { + autorest.Response `json:"-"` + Value *[]UserIdentityContract `json:"value,omitempty"` +} + // UserIdentityContract is user identity details. type UserIdentityContract struct { Provider *string `json:"provider,omitempty"` @@ -1127,3 +1520,12 @@ type UserUpdateParameters struct { State UserStateContract `json:"state,omitempty"` Note *string `json:"note,omitempty"` } + +// VirtualNetworkConfiguration is configuration of a virtual network to which +// API Management service is deployed. +type VirtualNetworkConfiguration struct { + Vnetid *string `json:"vnetid,omitempty"` + Subnetname *string `json:"subnetname,omitempty"` + SubnetResourceID *string `json:"subnetResourceId,omitempty"` + Location *string `json:"location,omitempty"` +} diff --git a/arm/apimanagement/networkstatus.go b/arm/apimanagement/networkstatus.go new file mode 100644 index 000000000000..11625067f4d9 --- /dev/null +++ b/arm/apimanagement/networkstatus.go @@ -0,0 +1,119 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// NetworkStatusClient is the composite Swagger for ApiManagement Client +type NetworkStatusClient struct { + ManagementClient +} + +// NewNetworkStatusClient creates an instance of the NetworkStatusClient +// client. +func NewNetworkStatusClient(subscriptionID string) NetworkStatusClient { + return NewNetworkStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNetworkStatusClientWithBaseURI creates an instance of the +// NetworkStatusClient client. +func NewNetworkStatusClientWithBaseURI(baseURI string, subscriptionID string) NetworkStatusClient { + return NetworkStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByService gets the Connectivity Status to the external resources on which +// the Api Management service depends from inside the Cloud Service. This also +// returns the DNS Servers as visible to the CloudService. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. +func (client NetworkStatusClient) GetByService(resourceGroupName string, serviceName string) (result NetworkStatusContract, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.NetworkStatusClient", "GetByService") + } + + req, err := client.GetByServicePreparer(resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "GetByService", nil, "Failure preparing request") + return + } + + resp, err := client.GetByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "GetByService", resp, "Failure sending request") + return + } + + result, err = client.GetByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "GetByService", resp, "Failure responding to request") + } + + return +} + +// GetByServicePreparer prepares the GetByService request. +func (client NetworkStatusClient) GetByServicePreparer(resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetByServiceSender sends the GetByService request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkStatusClient) GetByServiceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetByServiceResponder handles the response to the GetByService request. The method always +// closes the http.Response Body. +func (client NetworkStatusClient) GetByServiceResponder(resp *http.Response) (result NetworkStatusContract, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/apimanagement/openidconnectproviders.go b/arm/apimanagement/openidconnectproviders.go index 43c2e97e7d4d..5b63f1012a06 100755 --- a/arm/apimanagement/openidconnectproviders.go +++ b/arm/apimanagement/openidconnectproviders.go @@ -25,9 +25,8 @@ import ( "net/http" ) -// OpenIDConnectProvidersClient is the use these REST APIs for performing -// operations on entities like API, Product, and Subscription associated with -// your Azure API Management deployment. +// OpenIDConnectProvidersClient is the composite Swagger for ApiManagement +// Client type OpenIDConnectProvidersClient struct { ManagementClient } @@ -68,13 +67,15 @@ func (client OpenIDConnectProvidersClient) CreateOrUpdate(resourceGroupName stri req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, opid, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -94,7 +95,7 @@ func (client OpenIDConnectProvidersClient) CreateOrUpdatePreparer(resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -140,19 +141,24 @@ func (client OpenIDConnectProvidersClient) Delete(resourceGroupName string, serv {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.OpenIDConnectProvidersClient", "Delete") } req, err := client.DeletePreparer(resourceGroupName, serviceName, opid, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -172,7 +178,7 @@ func (client OpenIDConnectProvidersClient) DeletePreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -215,19 +221,24 @@ func (client OpenIDConnectProvidersClient) Get(resourceGroupName string, service {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.OpenIDConnectProvidersClient", "Get") } req, err := client.GetPreparer(resourceGroupName, serviceName, opid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -247,7 +258,7 @@ func (client OpenIDConnectProvidersClient) GetPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -307,13 +318,15 @@ func (client OpenIDConnectProvidersClient) ListByService(resourceGroupName strin req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -332,7 +345,7 @@ func (client OpenIDConnectProvidersClient) ListByServicePreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -409,19 +422,24 @@ func (client OpenIDConnectProvidersClient) Update(resourceGroupName string, serv {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.OpenIDConnectProvidersClient", "Update") } req, err := client.UpdatePreparer(resourceGroupName, serviceName, opid, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProvidersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -441,7 +459,7 @@ func (client OpenIDConnectProvidersClient) UpdatePreparer(resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/operations.go b/arm/apimanagement/operations.go new file mode 100644 index 000000000000..335c01805bca --- /dev/null +++ b/arm/apimanagement/operations.go @@ -0,0 +1,123 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the composite Swagger for ApiManagement Client +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations of the +// Microsoft.ApiManagement provider. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ApiManagement/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/apimanagement/policysnippets.go b/arm/apimanagement/policysnippets.go index d08eefea26fb..d54456bdd9ec 100755 --- a/arm/apimanagement/policysnippets.go +++ b/arm/apimanagement/policysnippets.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// PolicySnippetsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// PolicySnippetsClient is the composite Swagger for ApiManagement Client type PolicySnippetsClient struct { ManagementClient } @@ -48,7 +46,7 @@ func NewPolicySnippetsClientWithBaseURI(baseURI string, subscriptionID string) P // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. scope is policy scope. -func (client PolicySnippetsClient) ListByService(resourceGroupName string, serviceName string, scope PolicyScopeContract) (result ListPolicySnippetContract, err error) { +func (client PolicySnippetsClient) ListByService(resourceGroupName string, serviceName string, scope PolicyScopeContract) (result PolicySnippetsCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -59,13 +57,15 @@ func (client PolicySnippetsClient) ListByService(resourceGroupName string, servi req, err := client.ListByServicePreparer(resourceGroupName, serviceName, scope) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.PolicySnippetsClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.PolicySnippetsClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.PolicySnippetsClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.PolicySnippetsClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -84,7 +84,7 @@ func (client PolicySnippetsClient) ListByServicePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -108,12 +108,12 @@ func (client PolicySnippetsClient) ListByServiceSender(req *http.Request) (*http // ListByServiceResponder handles the response to the ListByService request. The method always // closes the http.Response Body. -func (client PolicySnippetsClient) ListByServiceResponder(resp *http.Response) (result ListPolicySnippetContract, err error) { +func (client PolicySnippetsClient) ListByServiceResponder(resp *http.Response) (result PolicySnippetsCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return diff --git a/arm/apimanagement/productapis.go b/arm/apimanagement/productapis.go index 32b4742a6382..8fedd872c771 100755 --- a/arm/apimanagement/productapis.go +++ b/arm/apimanagement/productapis.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// ProductApisClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// ProductApisClient is the composite Swagger for ApiManagement Client type ProductApisClient struct { ManagementClient } @@ -43,13 +41,13 @@ func NewProductApisClientWithBaseURI(baseURI string, subscriptionID string) Prod return ProductApisClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Add adds an API to the specified product. +// Create adds an API to the specified product. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. productID is product identifier. Must be // unique in the current API Management service instance. apiID is aPI // identifier. Must be unique in the current API Management service instance. -func (client ProductApisClient) Add(resourceGroupName string, serviceName string, productID string, apiID string) (result autorest.Response, err error) { +func (client ProductApisClient) Create(resourceGroupName string, serviceName string, productID string, apiID string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -63,30 +61,32 @@ func (client ProductApisClient) Add(resourceGroupName string, serviceName string Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductApisClient", "Add") + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductApisClient", "Create") } - req, err := client.AddPreparer(resourceGroupName, serviceName, productID, apiID) + req, err := client.CreatePreparer(resourceGroupName, serviceName, productID, apiID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Add", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Create", nil, "Failure preparing request") + return } - resp, err := client.AddSender(req) + resp, err := client.CreateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Add", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Create", resp, "Failure sending request") + return } - result, err = client.AddResponder(resp) + result, err = client.CreateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Add", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Create", resp, "Failure responding to request") } return } -// AddPreparer prepares the Add request. -func (client ProductApisClient) AddPreparer(resourceGroupName string, serviceName string, productID string, apiID string) (*http.Request, error) { +// CreatePreparer prepares the Create request. +func (client ProductApisClient) CreatePreparer(resourceGroupName string, serviceName string, productID string, apiID string) (*http.Request, error) { pathParameters := map[string]interface{}{ "apiId": autorest.Encode("path", apiID), "productId": autorest.Encode("path", productID), @@ -95,7 +95,7 @@ func (client ProductApisClient) AddPreparer(resourceGroupName string, serviceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -108,15 +108,15 @@ func (client ProductApisClient) AddPreparer(resourceGroupName string, serviceNam return preparer.Prepare(&http.Request{}) } -// AddSender sends the Add request. The method will close the +// CreateSender sends the Create request. The method will close the // http.Response Body if it receives an error. -func (client ProductApisClient) AddSender(req *http.Request) (*http.Response, error) { +func (client ProductApisClient) CreateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// AddResponder handles the response to the Add request. The method always +// CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client ProductApisClient) AddResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProductApisClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -126,25 +126,13 @@ func (client ProductApisClient) AddResponder(resp *http.Response) (result autore return } -// ListByProduct lists a collection of the APIs associated with a product. +// Delete deletes the specified API from the specified product. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. productID is product identifier. Must be -// unique in the current API Management service instance. filter is | Field -// | Supported operators | Supported functions | -// |-------------|------------------------|---------------------------------------------| -// | id | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | -// | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | -// | description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | -// | serviceUrl | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | -// | path | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | top is number of records to return. skip is number of records to -// skip. -func (client ProductApisClient) ListByProduct(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result APICollection, err error) { +// unique in the current API Management service instance. apiID is aPI +// identifier. Must be unique in the current API Management service instance. +func (client ProductApisClient) Delete(resourceGroupName string, serviceName string, productID string, apiID string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -154,115 +142,94 @@ func (client ProductApisClient) ListByProduct(resourceGroupName string, serviceN Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "productID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductApisClient", "ListByProduct") + {TargetValue: apiID, + Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductApisClient", "Delete") } - req, err := client.ListByProductPreparer(resourceGroupName, serviceName, productID, filter, top, skip) + req, err := client.DeletePreparer(resourceGroupName, serviceName, productID, apiID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProduct", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Delete", nil, "Failure preparing request") + return } - resp, err := client.ListByProductSender(req) + resp, err := client.DeleteSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProduct", resp, "Failure sending request") + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Delete", resp, "Failure sending request") + return } - result, err = client.ListByProductResponder(resp) + result, err = client.DeleteResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProduct", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Delete", resp, "Failure responding to request") } return } -// ListByProductPreparer prepares the ListByProduct request. -func (client ProductApisClient) ListByProductPreparer(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { +// DeletePreparer prepares the Delete request. +func (client ProductApisClient) DeletePreparer(resourceGroupName string, serviceName string, productID string, apiID string) (*http.Request, error) { pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiID), "productId": autorest.Encode("path", productID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } preparer := autorest.CreatePreparer( - autorest.AsGet(), + autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListByProductSender sends the ListByProduct request. The method will close the +// DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. -func (client ProductApisClient) ListByProductSender(req *http.Request) (*http.Response, error) { +func (client ProductApisClient) DeleteSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByProductResponder handles the response to the ListByProduct request. The method always +// DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client ProductApisClient) ListByProductResponder(resp *http.Response) (result APICollection, err error) { +func (client ProductApisClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByProductNextResults retrieves the next set of results, if any. -func (client ProductApisClient) ListByProductNextResults(lastResults APICollection) (result APICollection, err error) { - req, err := lastResults.APICollectionPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProduct", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListByProductSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProduct", resp, "Failure sending next results request") - } - - result, err = client.ListByProductResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProduct", resp, "Failure responding to next results request") - } - + result.Response = resp return } -// Remove deletes the specified API from the specified product. +// ListByProducts lists a collection of the APIs associated with a product. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. productID is product identifier. Must be -// unique in the current API Management service instance. apiID is aPI -// identifier. Must be unique in the current API Management service instance. -func (client ProductApisClient) Remove(resourceGroupName string, serviceName string, productID string, apiID string) (result autorest.Response, err error) { +// unique in the current API Management service instance. filter is | Field +// | Supported operators | Supported functions | +// |-------------|------------------------|---------------------------------------------| +// | id | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | +// | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | +// | description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | +// | serviceUrl | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | +// | path | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | top is number of records to return. skip is number of records to +// skip. +func (client ProductApisClient) ListByProducts(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result APICollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -272,69 +239,106 @@ func (client ProductApisClient) Remove(resourceGroupName string, serviceName str Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "productID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, - {TargetValue: apiID, - Constraints: []validation.Constraint{{Target: "apiID", Name: validation.MaxLength, Rule: 256, Chain: nil}, - {Target: "apiID", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "apiID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductApisClient", "Remove") + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductApisClient", "ListByProducts") } - req, err := client.RemovePreparer(resourceGroupName, serviceName, productID, apiID) + req, err := client.ListByProductsPreparer(resourceGroupName, serviceName, productID, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Remove", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProducts", nil, "Failure preparing request") + return } - resp, err := client.RemoveSender(req) + resp, err := client.ListByProductsSender(req) if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Remove", resp, "Failure sending request") + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProducts", resp, "Failure sending request") + return } - result, err = client.RemoveResponder(resp) + result, err = client.ListByProductsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "Remove", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProducts", resp, "Failure responding to request") } return } -// RemovePreparer prepares the Remove request. -func (client ProductApisClient) RemovePreparer(resourceGroupName string, serviceName string, productID string, apiID string) (*http.Request, error) { +// ListByProductsPreparer prepares the ListByProducts request. +func (client ProductApisClient) ListByProductsPreparer(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "apiId": autorest.Encode("path", apiID), "productId": autorest.Encode("path", productID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } preparer := autorest.CreatePreparer( - autorest.AsDelete(), + autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// RemoveSender sends the Remove request. The method will close the +// ListByProductsSender sends the ListByProducts request. The method will close the // http.Response Body if it receives an error. -func (client ProductApisClient) RemoveSender(req *http.Request) (*http.Response, error) { +func (client ProductApisClient) ListByProductsSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// RemoveResponder handles the response to the Remove request. The method always +// ListByProductsResponder handles the response to the ListByProducts request. The method always // closes the http.Response Body. -func (client ProductApisClient) RemoveResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProductApisClient) ListByProductsResponder(resp *http.Response) (result APICollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} + return +} + +// ListByProductsNextResults retrieves the next set of results, if any. +func (client ProductApisClient) ListByProductsNextResults(lastResults APICollection) (result APICollection, err error) { + req, err := lastResults.APICollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProducts", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByProductsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProducts", resp, "Failure sending next results request") + } + + result, err = client.ListByProductsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductApisClient", "ListByProducts", resp, "Failure responding to next results request") + } + return } diff --git a/arm/apimanagement/productgroups.go b/arm/apimanagement/productgroups.go index 7e4032b50624..15c1936675c8 100755 --- a/arm/apimanagement/productgroups.go +++ b/arm/apimanagement/productgroups.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// ProductGroupsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// ProductGroupsClient is the composite Swagger for ApiManagement Client type ProductGroupsClient struct { ManagementClient } @@ -44,14 +42,14 @@ func NewProductGroupsClientWithBaseURI(baseURI string, subscriptionID string) Pr return ProductGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Add adds the association between the specified developer group with the +// Create adds the association between the specified developer group with the // specified product. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. productID is product identifier. Must be // unique in the current API Management service instance. groupID is group // identifier. Must be unique in the current API Management service instance. -func (client ProductGroupsClient) Add(resourceGroupName string, serviceName string, productID string, groupID string) (result autorest.Response, err error) { +func (client ProductGroupsClient) Create(resourceGroupName string, serviceName string, productID string, groupID string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -65,30 +63,32 @@ func (client ProductGroupsClient) Add(resourceGroupName string, serviceName stri Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "groupID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductGroupsClient", "Add") + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductGroupsClient", "Create") } - req, err := client.AddPreparer(resourceGroupName, serviceName, productID, groupID) + req, err := client.CreatePreparer(resourceGroupName, serviceName, productID, groupID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Add", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Create", nil, "Failure preparing request") + return } - resp, err := client.AddSender(req) + resp, err := client.CreateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Add", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Create", resp, "Failure sending request") + return } - result, err = client.AddResponder(resp) + result, err = client.CreateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Add", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Create", resp, "Failure responding to request") } return } -// AddPreparer prepares the Add request. -func (client ProductGroupsClient) AddPreparer(resourceGroupName string, serviceName string, productID string, groupID string) (*http.Request, error) { +// CreatePreparer prepares the Create request. +func (client ProductGroupsClient) CreatePreparer(resourceGroupName string, serviceName string, productID string, groupID string) (*http.Request, error) { pathParameters := map[string]interface{}{ "groupId": autorest.Encode("path", groupID), "productId": autorest.Encode("path", productID), @@ -97,7 +97,7 @@ func (client ProductGroupsClient) AddPreparer(resourceGroupName string, serviceN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -110,15 +110,15 @@ func (client ProductGroupsClient) AddPreparer(resourceGroupName string, serviceN return preparer.Prepare(&http.Request{}) } -// AddSender sends the Add request. The method will close the +// CreateSender sends the Create request. The method will close the // http.Response Body if it receives an error. -func (client ProductGroupsClient) AddSender(req *http.Request) (*http.Response, error) { +func (client ProductGroupsClient) CreateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// AddResponder handles the response to the Add request. The method always +// CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client ProductGroupsClient) AddResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProductGroupsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -128,23 +128,13 @@ func (client ProductGroupsClient) AddResponder(resp *http.Response) (result auto return } -// ListByProduct lists the collection of developer groups associated with the -// specified product. +// Delete deletes the association between the specified group and product. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. productID is product identifier. Must be -// unique in the current API Management service instance. filter is | Field -// | Supported operators | Supported functions | -// |-------------|------------------------|---------------------------------------------| -// | id | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | -// | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | -// | description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | -// | type | eq, ne | N/A -// | top is number of records to return. skip is number of records to skip. -func (client ProductGroupsClient) ListByProduct(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result GroupCollection, err error) { +// unique in the current API Management service instance. groupID is group +// identifier. Must be unique in the current API Management service instance. +func (client ProductGroupsClient) Delete(resourceGroupName string, serviceName string, productID string, groupID string) (result ErrorBodyContract, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -154,115 +144,93 @@ func (client ProductGroupsClient) ListByProduct(resourceGroupName string, servic Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "productID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductGroupsClient", "ListByProduct") + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "groupID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductGroupsClient", "Delete") } - req, err := client.ListByProductPreparer(resourceGroupName, serviceName, productID, filter, top, skip) + req, err := client.DeletePreparer(resourceGroupName, serviceName, productID, groupID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProduct", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Delete", nil, "Failure preparing request") + return } - resp, err := client.ListByProductSender(req) + resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProduct", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Delete", resp, "Failure sending request") + return } - result, err = client.ListByProductResponder(resp) + result, err = client.DeleteResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProduct", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Delete", resp, "Failure responding to request") } return } -// ListByProductPreparer prepares the ListByProduct request. -func (client ProductGroupsClient) ListByProductPreparer(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { +// DeletePreparer prepares the Delete request. +func (client ProductGroupsClient) DeletePreparer(resourceGroupName string, serviceName string, productID string, groupID string) (*http.Request, error) { pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), "productId": autorest.Encode("path", productID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } preparer := autorest.CreatePreparer( - autorest.AsGet(), + autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListByProductSender sends the ListByProduct request. The method will close the +// DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. -func (client ProductGroupsClient) ListByProductSender(req *http.Request) (*http.Response, error) { +func (client ProductGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByProductResponder handles the response to the ListByProduct request. The method always +// DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client ProductGroupsClient) ListByProductResponder(resp *http.Response) (result GroupCollection, err error) { +func (client ProductGroupsClient) DeleteResponder(resp *http.Response) (result ErrorBodyContract, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusBadRequest), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } -// ListByProductNextResults retrieves the next set of results, if any. -func (client ProductGroupsClient) ListByProductNextResults(lastResults GroupCollection) (result GroupCollection, err error) { - req, err := lastResults.GroupCollectionPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProduct", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListByProductSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProduct", resp, "Failure sending next results request") - } - - result, err = client.ListByProductResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProduct", resp, "Failure responding to next results request") - } - - return -} - -// Remove deletes the association between the specified group and product. +// ListByProducts lists the collection of developer groups associated with the +// specified product. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. productID is product identifier. Must be -// unique in the current API Management service instance. groupID is group -// identifier. Must be unique in the current API Management service instance. -func (client ProductGroupsClient) Remove(resourceGroupName string, serviceName string, productID string, groupID string) (result ErrorBodyContract, err error) { +// unique in the current API Management service instance. filter is | Field +// | Supported operators | Supported functions | +// |-------------|------------------------|---------------------------------------------| +// | id | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | +// | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | +// | description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | +// | type | eq, ne | N/A +// | top is number of records to return. skip is number of records to skip. +func (client ProductGroupsClient) ListByProducts(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result GroupCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -272,70 +240,106 @@ func (client ProductGroupsClient) Remove(resourceGroupName string, serviceName s Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "productID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, - {TargetValue: groupID, - Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, - {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "groupID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductGroupsClient", "Remove") + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductGroupsClient", "ListByProducts") } - req, err := client.RemovePreparer(resourceGroupName, serviceName, productID, groupID) + req, err := client.ListByProductsPreparer(resourceGroupName, serviceName, productID, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Remove", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProducts", nil, "Failure preparing request") + return } - resp, err := client.RemoveSender(req) + resp, err := client.ListByProductsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Remove", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProducts", resp, "Failure sending request") + return } - result, err = client.RemoveResponder(resp) + result, err = client.ListByProductsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "Remove", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProducts", resp, "Failure responding to request") } return } -// RemovePreparer prepares the Remove request. -func (client ProductGroupsClient) RemovePreparer(resourceGroupName string, serviceName string, productID string, groupID string) (*http.Request, error) { +// ListByProductsPreparer prepares the ListByProducts request. +func (client ProductGroupsClient) ListByProductsPreparer(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), "productId": autorest.Encode("path", productID), "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } preparer := autorest.CreatePreparer( - autorest.AsDelete(), + autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// RemoveSender sends the Remove request. The method will close the +// ListByProductsSender sends the ListByProducts request. The method will close the // http.Response Body if it receives an error. -func (client ProductGroupsClient) RemoveSender(req *http.Request) (*http.Response, error) { +func (client ProductGroupsClient) ListByProductsSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// RemoveResponder handles the response to the Remove request. The method always +// ListByProductsResponder handles the response to the ListByProducts request. The method always // closes the http.Response Body. -func (client ProductGroupsClient) RemoveResponder(resp *http.Response) (result ErrorBodyContract, err error) { +func (client ProductGroupsClient) ListByProductsResponder(resp *http.Response) (result GroupCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusBadRequest), + azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } + +// ListByProductsNextResults retrieves the next set of results, if any. +func (client ProductGroupsClient) ListByProductsNextResults(lastResults GroupCollection) (result GroupCollection, err error) { + req, err := lastResults.GroupCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProducts", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByProductsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProducts", resp, "Failure sending next results request") + } + + result, err = client.ListByProductsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupsClient", "ListByProducts", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/apimanagement/productpolicy.go b/arm/apimanagement/productpolicy.go new file mode 100644 index 000000000000..7ed2e8146bb8 --- /dev/null +++ b/arm/apimanagement/productpolicy.go @@ -0,0 +1,290 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "io" + "net/http" +) + +// ProductPolicyClient is the composite Swagger for ApiManagement Client +type ProductPolicyClient struct { + ManagementClient +} + +// NewProductPolicyClient creates an instance of the ProductPolicyClient +// client. +func NewProductPolicyClient(subscriptionID string) ProductPolicyClient { + return NewProductPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductPolicyClientWithBaseURI creates an instance of the +// ProductPolicyClient client. +func NewProductPolicyClientWithBaseURI(baseURI string, subscriptionID string) ProductPolicyClient { + return ProductPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates policy configuration for the Product. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. productID is product identifier. Must be +// unique in the current API Management service instance. parameters is the +// policy contents to apply. parameters will be closed upon successful return. +// Callers should ensure closure when receiving an error.ifMatch is the entity +// state (Etag) version of the product policy to update. A value of "*" can be +// used for If-Match to unconditionally apply the operation. +func (client ProductPolicyClient) CreateOrUpdate(resourceGroupName string, serviceName string, productID string, parameters io.ReadCloser, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "productID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductPolicyClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, productID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ProductPolicyClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, productID string, parameters io.ReadCloser, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policy", pathParameters), + autorest.WithFile(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete deletes the policy configuration at the Product. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. productID is product identifier. Must be +// unique in the current API Management service instance. ifMatch is the entity +// state (Etag) version of the product policy to update. A value of "*" can be +// used for If-Match to unconditionally apply the operation. +func (client ProductPolicyClient) Delete(resourceGroupName string, serviceName string, productID string, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "productID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductPolicyClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, serviceName, productID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ProductPolicyClient) DeletePreparer(resourceGroupName string, serviceName string, productID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policy", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the policy configuration at the Product level. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. productID is product identifier. Must be +// unique in the current API Management service instance. +func (client ProductPolicyClient) Get(resourceGroupName string, serviceName string, productID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "productID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductPolicyClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, serviceName, productID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProductPolicyClient) GetPreparer(resourceGroupName string, serviceName string, productID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policy", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) GetResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/apimanagement/products.go b/arm/apimanagement/products.go index c77d2a7acc09..4c930436ba4a 100755 --- a/arm/apimanagement/products.go +++ b/arm/apimanagement/products.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// ProductsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// ProductsClient is the composite Swagger for ApiManagement Client type ProductsClient struct { ManagementClient } @@ -73,13 +71,15 @@ func (client ProductsClient) CreateOrUpdate(resourceGroupName string, serviceNam req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, productID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -99,7 +99,7 @@ func (client ProductsClient) CreateOrUpdatePreparer(resourceGroupName string, se "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -156,13 +156,15 @@ func (client ProductsClient) Delete(resourceGroupName string, serviceName string req, err := client.DeletePreparer(resourceGroupName, serviceName, productID, ifMatch, deleteSubscriptions) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -182,7 +184,7 @@ func (client ProductsClient) DeletePreparer(resourceGroupName string, serviceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -237,13 +239,15 @@ func (client ProductsClient) Get(resourceGroupName string, serviceName string, p req, err := client.GetPreparer(resourceGroupName, serviceName, productID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -263,7 +267,7 @@ func (client ProductsClient) GetPreparer(resourceGroupName string, serviceName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -331,13 +335,15 @@ func (client ProductsClient) ListByService(resourceGroupName string, serviceName req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip, expandGroups) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -356,7 +362,7 @@ func (client ProductsClient) ListByServicePreparer(resourceGroupName string, ser "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -447,13 +453,15 @@ func (client ProductsClient) Update(resourceGroupName string, serviceName string req, err := client.UpdatePreparer(resourceGroupName, serviceName, productID, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -473,7 +481,7 @@ func (client ProductsClient) UpdatePreparer(resourceGroupName string, serviceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/productsubscriptions.go b/arm/apimanagement/productsubscriptions.go index c55d05478729..51ee3d6cd322 100755 --- a/arm/apimanagement/productsubscriptions.go +++ b/arm/apimanagement/productsubscriptions.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// ProductSubscriptionsClient is the use these REST APIs for performing -// operations on entities like API, Product, and Subscription associated with -// your Azure API Management deployment. +// ProductSubscriptionsClient is the composite Swagger for ApiManagement Client type ProductSubscriptionsClient struct { ManagementClient } @@ -44,7 +42,7 @@ func NewProductSubscriptionsClientWithBaseURI(baseURI string, subscriptionID str return ProductSubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// ListByProduct lists the collection of subscriptions to the specified +// ListByProducts lists the collection of subscriptions to the specified // product. // // resourceGroupName is the name of the resource group. serviceName is the name @@ -64,7 +62,7 @@ func NewProductSubscriptionsClientWithBaseURI(baseURI string, subscriptionID str // endswith | // | state | eq | // | top is number of records to return. skip is number of records to skip. -func (client ProductSubscriptionsClient) ListByProduct(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result SubscriptionCollection, err error) { +func (client ProductSubscriptionsClient) ListByProducts(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result SubscriptionCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -80,30 +78,32 @@ func (client ProductSubscriptionsClient) ListByProduct(resourceGroupName string, {TargetValue: skip, Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductSubscriptionsClient", "ListByProduct") + return result, validation.NewErrorWithValidationError(err, "apimanagement.ProductSubscriptionsClient", "ListByProducts") } - req, err := client.ListByProductPreparer(resourceGroupName, serviceName, productID, filter, top, skip) + req, err := client.ListByProductsPreparer(resourceGroupName, serviceName, productID, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProduct", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProducts", nil, "Failure preparing request") + return } - resp, err := client.ListByProductSender(req) + resp, err := client.ListByProductsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProduct", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProducts", resp, "Failure sending request") + return } - result, err = client.ListByProductResponder(resp) + result, err = client.ListByProductsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProduct", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProducts", resp, "Failure responding to request") } return } -// ListByProductPreparer prepares the ListByProduct request. -func (client ProductSubscriptionsClient) ListByProductPreparer(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { +// ListByProductsPreparer prepares the ListByProducts request. +func (client ProductSubscriptionsClient) ListByProductsPreparer(resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "productId": autorest.Encode("path", productID), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -111,7 +111,7 @@ func (client ProductSubscriptionsClient) ListByProductPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -133,15 +133,15 @@ func (client ProductSubscriptionsClient) ListByProductPreparer(resourceGroupName return preparer.Prepare(&http.Request{}) } -// ListByProductSender sends the ListByProduct request. The method will close the +// ListByProductsSender sends the ListByProducts request. The method will close the // http.Response Body if it receives an error. -func (client ProductSubscriptionsClient) ListByProductSender(req *http.Request) (*http.Response, error) { +func (client ProductSubscriptionsClient) ListByProductsSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByProductResponder handles the response to the ListByProduct request. The method always +// ListByProductsResponder handles the response to the ListByProducts request. The method always // closes the http.Response Body. -func (client ProductSubscriptionsClient) ListByProductResponder(resp *http.Response) (result SubscriptionCollection, err error) { +func (client ProductSubscriptionsClient) ListByProductsResponder(resp *http.Response) (result SubscriptionCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -152,25 +152,25 @@ func (client ProductSubscriptionsClient) ListByProductResponder(resp *http.Respo return } -// ListByProductNextResults retrieves the next set of results, if any. -func (client ProductSubscriptionsClient) ListByProductNextResults(lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { +// ListByProductsNextResults retrieves the next set of results, if any. +func (client ProductSubscriptionsClient) ListByProductsNextResults(lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { req, err := lastResults.SubscriptionCollectionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProduct", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProducts", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByProductSender(req) + resp, err := client.ListByProductsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProduct", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProducts", resp, "Failure sending next results request") } - result, err = client.ListByProductResponder(resp) + result, err = client.ListByProductsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProduct", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "ListByProducts", resp, "Failure responding to next results request") } return diff --git a/arm/apimanagement/properties.go b/arm/apimanagement/properties.go new file mode 100644 index 000000000000..10d6f1efd5d5 --- /dev/null +++ b/arm/apimanagement/properties.go @@ -0,0 +1,163 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// PropertiesClient is the composite Swagger for ApiManagement Client +type PropertiesClient struct { + ManagementClient +} + +// NewPropertiesClient creates an instance of the PropertiesClient client. +func NewPropertiesClient(subscriptionID string) PropertiesClient { + return NewPropertiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPropertiesClientWithBaseURI creates an instance of the PropertiesClient +// client. +func NewPropertiesClientWithBaseURI(baseURI string, subscriptionID string) PropertiesClient { + return PropertiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByService lists a collection of properties defined within a service +// instance. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. filter is | Field | Supported operators | +// Supported functions | +// |-------|------------------------|-------------------------------------------------------| +// | tags | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith, any, all | +// | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith | top is number of records to return. skip is number of +// records to skip. +func (client PropertiesClient) ListByService(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PropertyCollection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.PropertiesClient", "ListByService") + } + + req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PropertiesClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PropertiesClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PropertiesClient", "ListByService", resp, "Failure responding to request") + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PropertiesClient) ListByServicePreparer(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PropertiesClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PropertiesClient) ListByServiceResponder(resp *http.Response) (result PropertyCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServiceNextResults retrieves the next set of results, if any. +func (client PropertiesClient) ListByServiceNextResults(lastResults PropertyCollection) (result PropertyCollection, err error) { + req, err := lastResults.PropertyCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.PropertiesClient", "ListByService", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.PropertiesClient", "ListByService", resp, "Failure sending next results request") + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PropertiesClient", "ListByService", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/apimanagement/property.go b/arm/apimanagement/property.go index 75a068be41eb..b39dc58190bb 100755 --- a/arm/apimanagement/property.go +++ b/arm/apimanagement/property.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// PropertyClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// PropertyClient is the composite Swagger for ApiManagement Client type PropertyClient struct { ManagementClient } @@ -74,13 +72,15 @@ func (client PropertyClient) CreateOrUpdate(resourceGroupName string, serviceNam req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, propID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -100,7 +100,7 @@ func (client PropertyClient) CreateOrUpdatePreparer(resourceGroupName string, se "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -145,19 +145,24 @@ func (client PropertyClient) Delete(resourceGroupName string, serviceName string {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: propID, + Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "propID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.PropertyClient", "Delete") } req, err := client.DeletePreparer(resourceGroupName, serviceName, propID, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -177,7 +182,7 @@ func (client PropertyClient) DeletePreparer(resourceGroupName string, serviceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -219,19 +224,24 @@ func (client PropertyClient) Get(resourceGroupName string, serviceName string, p {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: propID, + Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "propID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.PropertyClient", "Get") } req, err := client.GetPreparer(resourceGroupName, serviceName, propID) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -251,7 +261,7 @@ func (client PropertyClient) GetPreparer(resourceGroupName string, serviceName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -283,125 +293,6 @@ func (client PropertyClient) GetResponder(resp *http.Response) (result PropertyC return } -// ListByService lists a collection of properties defined within a service -// instance. -// -// resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. filter is | Field | Supported operators | -// Supported functions | -// |-------|------------------------|-------------------------------------------------------| -// | tags | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith, any, all | -// | name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, -// endswith | top is number of records to return. skip is number of -// records to skip. -func (client PropertyClient) ListByService(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PropertyCollection, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: serviceName, - Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.PropertyClient", "ListByService") - } - - req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", nil, "Failure preparing request") - } - - resp, err := client.ListByServiceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", resp, "Failure sending request") - } - - result, err = client.ListByServiceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", resp, "Failure responding to request") - } - - return -} - -// ListByServicePreparer prepares the ListByService request. -func (client PropertyClient) ListByServicePreparer(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "serviceName": autorest.Encode("path", serviceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-07-07" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/properties", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListByServiceSender sends the ListByService request. The method will close the -// http.Response Body if it receives an error. -func (client PropertyClient) ListByServiceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListByServiceResponder handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (client PropertyClient) ListByServiceResponder(resp *http.Response) (result PropertyCollection, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByServiceNextResults retrieves the next set of results, if any. -func (client PropertyClient) ListByServiceNextResults(lastResults PropertyCollection) (result PropertyCollection, err error) { - req, err := lastResults.PropertyCollectionPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListByServiceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", resp, "Failure sending next results request") - } - - result, err = client.ListByServiceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "ListByService", resp, "Failure responding to next results request") - } - - return -} - // Update updates the specific property. // // resourceGroupName is the name of the resource group. serviceName is the name @@ -414,19 +305,24 @@ func (client PropertyClient) Update(resourceGroupName string, serviceName string {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: propID, + Constraints: []validation.Constraint{{Target: "propID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "propID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.PropertyClient", "Update") } req, err := client.UpdatePreparer(resourceGroupName, serviceName, propID, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.PropertyClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -446,7 +342,7 @@ func (client PropertyClient) UpdatePreparer(resourceGroupName string, serviceNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/quotabycounterkeys.go b/arm/apimanagement/quotabycounterkeys.go index c77bdbabd060..f6f16c90375c 100755 --- a/arm/apimanagement/quotabycounterkeys.go +++ b/arm/apimanagement/quotabycounterkeys.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// QuotaByCounterKeysClient is the use these REST APIs for performing -// operations on entities like API, Product, and Subscription associated with -// your Azure API Management deployment. +// QuotaByCounterKeysClient is the composite Swagger for ApiManagement Client type QuotaByCounterKeysClient struct { ManagementClient } @@ -62,13 +60,15 @@ func (client QuotaByCounterKeysClient) ListByService(resourceGroupName string, s req, err := client.ListByServicePreparer(resourceGroupName, serviceName, quotaCounterKey) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -88,7 +88,7 @@ func (client QuotaByCounterKeysClient) ListByServicePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -139,13 +139,15 @@ func (client QuotaByCounterKeysClient) Update(resourceGroupName string, serviceN req, err := client.UpdatePreparer(resourceGroupName, serviceName, quotaCounterKey, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -165,7 +167,7 @@ func (client QuotaByCounterKeysClient) UpdatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/quotabyperiodkeys.go b/arm/apimanagement/quotabyperiodkeys.go index e054f391c831..20da7fe1facc 100755 --- a/arm/apimanagement/quotabyperiodkeys.go +++ b/arm/apimanagement/quotabyperiodkeys.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// QuotaByPeriodKeysClient is the use these REST APIs for performing operations -// on entities like API, Product, and Subscription associated with your Azure -// API Management deployment. +// QuotaByPeriodKeysClient is the composite Swagger for ApiManagement Client type QuotaByPeriodKeysClient struct { ManagementClient } @@ -61,13 +59,15 @@ func (client QuotaByPeriodKeysClient) Get(resourceGroupName string, serviceName req, err := client.GetPreparer(resourceGroupName, serviceName, quotaCounterKey, quotaPeriodKey) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -88,7 +88,7 @@ func (client QuotaByPeriodKeysClient) GetPreparer(resourceGroupName string, serv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -138,13 +138,15 @@ func (client QuotaByPeriodKeysClient) Update(resourceGroupName string, serviceNa req, err := client.UpdatePreparer(resourceGroupName, serviceName, quotaCounterKey, quotaPeriodKey, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -165,7 +167,7 @@ func (client QuotaByPeriodKeysClient) UpdatePreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/regions.go b/arm/apimanagement/regions.go index bad1f43d8d25..abc3227f096c 100755 --- a/arm/apimanagement/regions.go +++ b/arm/apimanagement/regions.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// RegionsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// RegionsClient is the composite Swagger for ApiManagement Client type RegionsClient struct { ManagementClient } @@ -57,13 +55,15 @@ func (client RegionsClient) ListByService(resourceGroupName string, serviceName req, err := client.ListByServicePreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.RegionsClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.RegionsClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.RegionsClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.RegionsClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -82,7 +82,7 @@ func (client RegionsClient) ListByServicePreparer(resourceGroupName string, serv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/reports.go b/arm/apimanagement/reports.go index 29986fe3189f..83b12cb6f42d 100755 --- a/arm/apimanagement/reports.go +++ b/arm/apimanagement/reports.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// ReportsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// ReportsClient is the composite Swagger for ApiManagement Client type ReportsClient struct { ManagementClient } @@ -53,7 +51,7 @@ func NewReportsClientWithBaseURI(baseURI string, subscriptionID string) ReportsC // (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to // convert TimSpan to a valid interval string: XmlConvert.ToString(new // TimeSpan(hours, minutes, secconds)) -func (client ReportsClient) ListByService(resourceGroupName string, serviceName string, aggregation ReportsAggregation, filter string, top *int32, skip *int32, interval string) (result ReportCollection, err error) { +func (client ReportsClient) ListByService(resourceGroupName string, serviceName string, aggregation ReportsAggregation, filter string, top *int32, skip *int32, interval *string) (result ReportCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -70,13 +68,15 @@ func (client ReportsClient) ListByService(resourceGroupName string, serviceName req, err := client.ListByServicePreparer(resourceGroupName, serviceName, aggregation, filter, top, skip, interval) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -88,7 +88,7 @@ func (client ReportsClient) ListByService(resourceGroupName string, serviceName } // ListByServicePreparer prepares the ListByService request. -func (client ReportsClient) ListByServicePreparer(resourceGroupName string, serviceName string, aggregation ReportsAggregation, filter string, top *int32, skip *int32, interval string) (*http.Request, error) { +func (client ReportsClient) ListByServicePreparer(resourceGroupName string, serviceName string, aggregation ReportsAggregation, filter string, top *int32, skip *int32, interval *string) (*http.Request, error) { pathParameters := map[string]interface{}{ "aggregation": autorest.Encode("path", aggregation), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -96,7 +96,7 @@ func (client ReportsClient) ListByServicePreparer(resourceGroupName string, serv "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -109,8 +109,8 @@ func (client ReportsClient) ListByServicePreparer(resourceGroupName string, serv if skip != nil { queryParameters["$skip"] = autorest.Encode("query", *skip) } - if len(interval) > 0 { - queryParameters["interval"] = autorest.Encode("query", interval) + if interval != nil { + queryParameters["interval"] = autorest.Encode("query", *interval) } preparer := autorest.CreatePreparer( diff --git a/arm/apimanagement/services.go b/arm/apimanagement/services.go new file mode 100644 index 000000000000..7a396f263004 --- /dev/null +++ b/arm/apimanagement/services.go @@ -0,0 +1,1278 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ServicesClient is the composite Swagger for ApiManagement Client +type ServicesClient struct { + ManagementClient +} + +// NewServicesClient creates an instance of the ServicesClient client. +func NewServicesClient(subscriptionID string) ServicesClient { + return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicesClientWithBaseURI creates an instance of the ServicesClient +// client. +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ApplyNetworkConfigurationUpdates updates the Microsoft.ApiManagement +// resource running in the Virtual network to pick the updated network +// settings. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. +func (client ServicesClient) ApplyNetworkConfigurationUpdates(resourceGroupName string, serviceName string, cancel <-chan struct{}) (<-chan ServiceResource, <-chan error) { + resultChan := make(chan ServiceResource, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "ApplyNetworkConfigurationUpdates") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ServiceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ApplyNetworkConfigurationUpdatesPreparer(resourceGroupName, serviceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ApplyNetworkConfigurationUpdates", nil, "Failure preparing request") + return + } + + resp, err := client.ApplyNetworkConfigurationUpdatesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ApplyNetworkConfigurationUpdates", resp, "Failure sending request") + return + } + + result, err = client.ApplyNetworkConfigurationUpdatesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ApplyNetworkConfigurationUpdates", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ApplyNetworkConfigurationUpdatesPreparer prepares the ApplyNetworkConfigurationUpdates request. +func (client ServicesClient) ApplyNetworkConfigurationUpdatesPreparer(resourceGroupName string, serviceName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ApplyNetworkConfigurationUpdatesSender sends the ApplyNetworkConfigurationUpdates request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ApplyNetworkConfigurationUpdatesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ApplyNetworkConfigurationUpdatesResponder handles the response to the ApplyNetworkConfigurationUpdates request. The method always +// closes the http.Response Body. +func (client ServicesClient) ApplyNetworkConfigurationUpdatesResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Backup creates a backup of the API Management service to the given Azure +// Storage Account. This is long running operation and could take several +// minutes to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is parameters supplied to the +// ApiManagementServices_Backup operation. +func (client ServicesClient) Backup(resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, cancel <-chan struct{}) (<-chan ServiceResource, <-chan error) { + resultChan := make(chan ServiceResource, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "Backup") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ServiceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.BackupPreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Backup", nil, "Failure preparing request") + return + } + + resp, err := client.BackupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Backup", resp, "Failure sending request") + return + } + + result, err = client.BackupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Backup", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// BackupPreparer prepares the Backup request. +func (client ServicesClient) BackupPreparer(resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// BackupSender sends the Backup request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) BackupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// BackupResponder handles the response to the Backup request. The method always +// closes the http.Response Body. +func (client ServicesClient) BackupResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CheckNameAvailability checks availability and correctness of a name for an +// API Management service. +// +// parameters is parameters supplied to the CheckNameAvailability operation. +func (client ServicesClient) CheckNameAvailability(parameters ServiceCheckNameAvailabilityParameters) (result ServiceNameAvailabilityResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "CheckNameAvailability") + } + + req, err := client.CheckNameAvailabilityPreparer(parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "CheckNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServicesClient) CheckNameAvailabilityPreparer(parameters ServiceCheckNameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServicesClient) CheckNameAvailabilityResponder(resp *http.Response) (result ServiceNameAvailabilityResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates an API Management service. This is long +// running operation and could take several minutes to complete. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is parameters supplied to the +// CreateOrUpdate API Management service operation. +func (client ServicesClient) CreateOrUpdate(resourceGroupName string, serviceName string, parameters ServiceResource) (result ServiceResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServiceProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.MaxLength, Rule: 100, Chain: nil}}}, + {Target: "parameters.ServiceProperties.PublisherName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ServiceProperties.Vpnconfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.Vpnconfiguration.SubnetResourceID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.Vpnconfiguration.SubnetResourceID", Name: validation.Pattern, Rule: `^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$`, Chain: nil}}}, + }}, + }}, + {Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServicesClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, parameters ServiceResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing API Management service. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. +func (client ServicesClient) Delete(resourceGroupName string, serviceName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicesClient) DeletePreparer(resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an API Management service resource description. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. +func (client ServicesClient) Get(resourceGroupName string, serviceName string) (result ServiceResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicesClient) GetPreparer(resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServicesClient) GetResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSsoToken gets the Single-Sign-On token for the API Management Service +// which is valid for 5 Minutes. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. +func (client ServicesClient) GetSsoToken(resourceGroupName string, serviceName string) (result ServiceGetSsoTokenResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "GetSsoToken") + } + + req, err := client.GetSsoTokenPreparer(resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "GetSsoToken", nil, "Failure preparing request") + return + } + + resp, err := client.GetSsoTokenSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "GetSsoToken", resp, "Failure sending request") + return + } + + result, err = client.GetSsoTokenResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "GetSsoToken", resp, "Failure responding to request") + } + + return +} + +// GetSsoTokenPreparer prepares the GetSsoToken request. +func (client ServicesClient) GetSsoTokenPreparer(resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSsoTokenSender sends the GetSsoToken request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) GetSsoTokenSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetSsoTokenResponder handles the response to the GetSsoToken request. The method always +// closes the http.Response Body. +func (client ServicesClient) GetSsoTokenResponder(resp *http.Response) (result ServiceGetSsoTokenResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all API Management services within an Azure subscription. +func (client ServicesClient) List() (result ServiceListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServicesClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service/", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListResponder(resp *http.Response) (result ServiceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ServicesClient) ListNextResults(lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.ServiceListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup list all API Management services within a resource +// group. +// +// resourceGroupName is the name of the resource group. +func (client ServicesClient) ListByResourceGroup(resourceGroupName string) (result ServiceListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServicesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServicesClient) ListByResourceGroupNextResults(lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.ServiceListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// ManageDeployments manages deployments of an API Management service. This +// operation can be used to do the following: Change SKU, Change SKU Units, +// Change Service Tier (Developer/Standard/Premium) and Manage VPN +// Configuration. This is a long running operation and can take several minutes +// to complete. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is parameters supplied to the +// ManageDeployments operation. +func (client ServicesClient) ManageDeployments(resourceGroupName string, serviceName string, parameters ServiceManageDeploymentsParameters, cancel <-chan struct{}) (<-chan ServiceResource, <-chan error) { + resultChan := make(chan ServiceResource, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.VpnConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.VpnConfiguration.SubnetResourceID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.VpnConfiguration.SubnetResourceID", Name: validation.Pattern, Rule: `^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$`, Chain: nil}}}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "ManageDeployments") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ServiceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ManageDeploymentsPreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ManageDeployments", nil, "Failure preparing request") + return + } + + resp, err := client.ManageDeploymentsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ManageDeployments", resp, "Failure sending request") + return + } + + result, err = client.ManageDeploymentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "ManageDeployments", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ManageDeploymentsPreparer prepares the ManageDeployments request. +func (client ServicesClient) ManageDeploymentsPreparer(resourceGroupName string, serviceName string, parameters ServiceManageDeploymentsParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/managedeployments", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ManageDeploymentsSender sends the ManageDeployments request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ManageDeploymentsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ManageDeploymentsResponder handles the response to the ManageDeployments request. The method always +// closes the http.Response Body. +func (client ServicesClient) ManageDeploymentsResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Restore restores a backup of an API Management service created using the +// ApiManagementServices_Backup operation on the current service. This is a +// long running operation and could take several minutes to complete. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is parameters supplied to the +// Restore API Management service from backup operation. +func (client ServicesClient) Restore(resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, cancel <-chan struct{}) (<-chan ServiceResource, <-chan error) { + resultChan := make(chan ServiceResource, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "Restore") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ServiceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RestorePreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Restore", nil, "Failure preparing request") + return + } + + resp, err := client.RestoreSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Restore", resp, "Failure sending request") + return + } + + result, err = client.RestoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Restore", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// RestorePreparer prepares the Restore request. +func (client ServicesClient) RestorePreparer(resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RestoreSender sends the Restore request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) RestoreSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RestoreResponder handles the response to the Restore request. The method always +// closes the http.Response Body. +func (client ServicesClient) RestoreResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing API Management service. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is parameters supplied to the +// CreateOrUpdate API Management service operation. +func (client ServicesClient) Update(resourceGroupName string, serviceName string, parameters ServiceUpdateParameters, cancel <-chan struct{}) (<-chan ServiceResource, <-chan error) { + resultChan := make(chan ServiceResource, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "Update") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ServiceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client ServicesClient) UpdatePreparer(resourceGroupName string, serviceName string, parameters ServiceUpdateParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServicesClient) UpdateResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateHostname creates, updates, or deletes the custom hostnames for an API +// Management service. The custom hostname can be applied to the Proxy and +// Portal endpoint. This is a long running operation and could take several +// minutes to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is parameters supplied to the +// UpdateHostname operation. +func (client ServicesClient) UpdateHostname(resourceGroupName string, serviceName string, parameters ServiceUpdateHostnameParameters, cancel <-chan struct{}) (<-chan ServiceResource, <-chan error) { + resultChan := make(chan ServiceResource, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "UpdateHostname") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ServiceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdateHostnamePreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "UpdateHostname", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateHostnameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "UpdateHostname", resp, "Failure sending request") + return + } + + result, err = client.UpdateHostnameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "UpdateHostname", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdateHostnamePreparer prepares the UpdateHostname request. +func (client ServicesClient) UpdateHostnamePreparer(resourceGroupName string, serviceName string, parameters ServiceUpdateHostnameParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/updatehostname", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateHostnameSender sends the UpdateHostname request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) UpdateHostnameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateHostnameResponder handles the response to the UpdateHostname request. The method always +// closes the http.Response Body. +func (client ServicesClient) UpdateHostnameResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UploadCertificate upload Custom Domain SSL certificate for an API Management +// service. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is parameters supplied to the +// Upload SSL certificate for an API Management service operation. +func (client ServicesClient) UploadCertificate(resourceGroupName string, serviceName string, parameters ServiceUploadCertificateParameters) (result CertificateInformation, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Certificate", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CertificatePassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.ServicesClient", "UploadCertificate") + } + + req, err := client.UploadCertificatePreparer(resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "UploadCertificate", nil, "Failure preparing request") + return + } + + resp, err := client.UploadCertificateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "UploadCertificate", resp, "Failure sending request") + return + } + + result, err = client.UploadCertificateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServicesClient", "UploadCertificate", resp, "Failure responding to request") + } + + return +} + +// UploadCertificatePreparer prepares the UploadCertificate request. +func (client ServicesClient) UploadCertificatePreparer(resourceGroupName string, serviceName string, parameters ServiceUploadCertificateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/uploadcertificate", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UploadCertificateSender sends the UploadCertificate request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) UploadCertificateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UploadCertificateResponder handles the response to the UploadCertificate request. The method always +// closes the http.Response Body. +func (client ServicesClient) UploadCertificateResponder(resp *http.Response) (result CertificateInformation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/apimanagement/subscriptions.go b/arm/apimanagement/subscriptions.go index 678f8ff97299..edd18aca275d 100755 --- a/arm/apimanagement/subscriptions.go +++ b/arm/apimanagement/subscriptions.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// SubscriptionsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// SubscriptionsClient is the composite Swagger for ApiManagement Client type SubscriptionsClient struct { ManagementClient } @@ -48,8 +46,9 @@ func NewSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) Su // specified product. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. sid is identifier of the subscription. -// parameters is create parameters. +// of the API Management service. sid is subscription entity Identifier. The +// entity represents the association between a user and a product in API +// Management. parameters is create parameters. func (client SubscriptionsClient) CreateOrUpdate(resourceGroupName string, serviceName string, sid string, parameters SubscriptionCreateParameters) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, @@ -58,7 +57,6 @@ func (client SubscriptionsClient) CreateOrUpdate(resourceGroupName string, servi {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, {TargetValue: sid, Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, - {Target: "sid", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.UserID", Name: validation.Null, Rule: true, Chain: nil}, @@ -80,13 +78,15 @@ func (client SubscriptionsClient) CreateOrUpdate(resourceGroupName string, servi req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, sid, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -106,7 +106,7 @@ func (client SubscriptionsClient) CreateOrUpdatePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -142,28 +142,34 @@ func (client SubscriptionsClient) CreateOrUpdateResponder(resp *http.Response) ( // Delete deletes the specified subscription. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. sid is identifier of the subscription. -// ifMatch is eTag of the Subscription Entity. ETag should match the current -// entity state from the header response of the GET request or it should be * -// for unconditional update. +// of the API Management service. sid is subscription entity Identifier. The +// entity represents the association between a user and a product in API +// Management. ifMatch is eTag of the Subscription Entity. ETag should match +// the current entity state from the header response of the GET request or it +// should be * for unconditional update. func (client SubscriptionsClient) Delete(resourceGroupName string, serviceName string, sid string, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.SubscriptionsClient", "Delete") } req, err := client.DeletePreparer(resourceGroupName, serviceName, sid, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -183,7 +189,7 @@ func (client SubscriptionsClient) DeletePreparer(resourceGroupName string, servi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -218,25 +224,32 @@ func (client SubscriptionsClient) DeleteResponder(resp *http.Response) (result a // Get gets the specified Subscription entity. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. sid is identifier of the subscription. +// of the API Management service. sid is subscription entity Identifier. The +// entity represents the association between a user and a product in API +// Management. func (client SubscriptionsClient) Get(resourceGroupName string, serviceName string, sid string) (result SubscriptionContract, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.SubscriptionsClient", "Get") } req, err := client.GetPreparer(resourceGroupName, serviceName, sid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -256,7 +269,7 @@ func (client SubscriptionsClient) GetPreparer(resourceGroupName string, serviceN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -288,8 +301,7 @@ func (client SubscriptionsClient) GetResponder(resp *http.Response) (result Subs return } -// ListByService lists all subscriptions of the API Management service -// instance. +// List lists all subscriptions of the API Management service instance. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. filter is | Field | Supported @@ -307,7 +319,7 @@ func (client SubscriptionsClient) GetResponder(resp *http.Response) (result Subs // endswith | // | state | eq | // | top is number of records to return. skip is number of records to skip. -func (client SubscriptionsClient) ListByService(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result SubscriptionCollection, err error) { +func (client SubscriptionsClient) List(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result SubscriptionCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -319,37 +331,39 @@ func (client SubscriptionsClient) ListByService(resourceGroupName string, servic {TargetValue: skip, Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.SubscriptionsClient", "ListByService") + return result, validation.NewErrorWithValidationError(err, "apimanagement.SubscriptionsClient", "List") } - req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) + req, err := client.ListPreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "List", nil, "Failure preparing request") + return } - resp, err := client.ListByServiceSender(req) + resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "List", resp, "Failure sending request") + return } - result, err = client.ListByServiceResponder(resp) + result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "ListByService", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "List", resp, "Failure responding to request") } return } -// ListByServicePreparer prepares the ListByService request. -func (client SubscriptionsClient) ListByServicePreparer(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { +// ListPreparer prepares the List request. +func (client SubscriptionsClient) ListPreparer(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -371,15 +385,15 @@ func (client SubscriptionsClient) ListByServicePreparer(resourceGroupName string return preparer.Prepare(&http.Request{}) } -// ListByServiceSender sends the ListByService request. The method will close the +// ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client SubscriptionsClient) ListByServiceSender(req *http.Request) (*http.Response, error) { +func (client SubscriptionsClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByServiceResponder handles the response to the ListByService request. The method always +// ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client SubscriptionsClient) ListByServiceResponder(resp *http.Response) (result SubscriptionCollection, err error) { +func (client SubscriptionsClient) ListResponder(resp *http.Response) (result SubscriptionCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -390,25 +404,25 @@ func (client SubscriptionsClient) ListByServiceResponder(resp *http.Response) (r return } -// ListByServiceNextResults retrieves the next set of results, if any. -func (client SubscriptionsClient) ListByServiceNextResults(lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { +// ListNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) ListNextResults(lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { req, err := lastResults.SubscriptionCollectionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "ListByService", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "List", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByServiceSender(req) + resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "ListByService", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "List", resp, "Failure sending next results request") } - result, err = client.ListByServiceResponder(resp) + result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "ListByService", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "List", resp, "Failure responding to next results request") } return @@ -418,25 +432,32 @@ func (client SubscriptionsClient) ListByServiceNextResults(lastResults Subscript // API Management service instance. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. sid is identifier of the subscription. +// of the API Management service. sid is subscription entity Identifier. The +// entity represents the association between a user and a product in API +// Management. func (client SubscriptionsClient) RegeneratePrimaryKey(resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.SubscriptionsClient", "RegeneratePrimaryKey") } req, err := client.RegeneratePrimaryKeyPreparer(resourceGroupName, serviceName, sid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + return } resp, err := client.RegeneratePrimaryKeySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegeneratePrimaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegeneratePrimaryKey", resp, "Failure sending request") + return } result, err = client.RegeneratePrimaryKeyResponder(resp) @@ -456,7 +477,7 @@ func (client SubscriptionsClient) RegeneratePrimaryKeyPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -491,25 +512,32 @@ func (client SubscriptionsClient) RegeneratePrimaryKeyResponder(resp *http.Respo // the API Management service instance. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. sid is identifier of the subscription. +// of the API Management service. sid is subscription entity Identifier. The +// entity represents the association between a user and a product in API +// Management. func (client SubscriptionsClient) RegenerateSecondaryKey(resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.SubscriptionsClient", "RegenerateSecondaryKey") } req, err := client.RegenerateSecondaryKeyPreparer(resourceGroupName, serviceName, sid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateSecondaryKeySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegenerateSecondaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "RegenerateSecondaryKey", resp, "Failure sending request") + return } result, err = client.RegenerateSecondaryKeyResponder(resp) @@ -529,7 +557,7 @@ func (client SubscriptionsClient) RegenerateSecondaryKeyPreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -563,28 +591,35 @@ func (client SubscriptionsClient) RegenerateSecondaryKeyResponder(resp *http.Res // Update updates the details of a subscription specificied by its identifier. // // resourceGroupName is the name of the resource group. serviceName is the name -// of the API Management service. sid is identifier of the subscription. -// parameters is update parameters. ifMatch is eTag of the Subscription Entity. -// ETag should match the current entity state from the header response of the -// GET request or it should be * for unconditional update. +// of the API Management service. sid is subscription entity Identifier. The +// entity represents the association between a user and a product in API +// Management. parameters is update parameters. ifMatch is eTag of the +// Subscription Entity. ETag should match the current entity state from the +// header response of the GET request or it should be * for unconditional +// update. func (client SubscriptionsClient) Update(resourceGroupName string, serviceName string, sid string, parameters SubscriptionUpdateParameters, ifMatch string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "apimanagement.SubscriptionsClient", "Update") } req, err := client.UpdatePreparer(resourceGroupName, serviceName, sid, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -604,7 +639,7 @@ func (client SubscriptionsClient) UpdatePreparer(resourceGroupName string, servi "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/tenantaccess.go b/arm/apimanagement/tenantaccess.go index 728a144ee305..531b9913c003 100755 --- a/arm/apimanagement/tenantaccess.go +++ b/arm/apimanagement/tenantaccess.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// TenantAccessClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// TenantAccessClient is the composite Swagger for ApiManagement Client type TenantAccessClient struct { ManagementClient } @@ -58,13 +56,15 @@ func (client TenantAccessClient) Get(resourceGroupName string, serviceName strin req, err := client.GetPreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -83,7 +83,7 @@ func (client TenantAccessClient) GetPreparer(resourceGroupName string, serviceNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -130,13 +130,15 @@ func (client TenantAccessClient) RegeneratePrimaryKey(resourceGroupName string, req, err := client.RegeneratePrimaryKeyPreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + return } resp, err := client.RegeneratePrimaryKeySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", resp, "Failure sending request") + return } result, err = client.RegeneratePrimaryKeyResponder(resp) @@ -155,7 +157,7 @@ func (client TenantAccessClient) RegeneratePrimaryKeyPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -201,13 +203,15 @@ func (client TenantAccessClient) RegenerateSecondaryKey(resourceGroupName string req, err := client.RegenerateSecondaryKeyPreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateSecondaryKeySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", resp, "Failure sending request") + return } result, err = client.RegenerateSecondaryKeyResponder(resp) @@ -226,7 +230,7 @@ func (client TenantAccessClient) RegenerateSecondaryKeyPreparer(resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -274,13 +278,15 @@ func (client TenantAccessClient) Update(resourceGroupName string, serviceName st req, err := client.UpdatePreparer(resourceGroupName, serviceName, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -299,7 +305,7 @@ func (client TenantAccessClient) UpdatePreparer(resourceGroupName string, servic "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/tenantaccessgit.go b/arm/apimanagement/tenantaccessgit.go index 6ff6ee2d1d86..7d5a67c38c5f 100755 --- a/arm/apimanagement/tenantaccessgit.go +++ b/arm/apimanagement/tenantaccessgit.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// TenantAccessGitClient is the use these REST APIs for performing operations -// on entities like API, Product, and Subscription associated with your Azure -// API Management deployment. +// TenantAccessGitClient is the composite Swagger for ApiManagement Client type TenantAccessGitClient struct { ManagementClient } @@ -59,13 +57,15 @@ func (client TenantAccessGitClient) Get(resourceGroupName string, serviceName st req, err := client.GetPreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -84,7 +84,7 @@ func (client TenantAccessGitClient) GetPreparer(resourceGroupName string, servic "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -131,13 +131,15 @@ func (client TenantAccessGitClient) RegeneratePrimaryKey(resourceGroupName strin req, err := client.RegeneratePrimaryKeyPreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + return } resp, err := client.RegeneratePrimaryKeySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", resp, "Failure sending request") + return } result, err = client.RegeneratePrimaryKeyResponder(resp) @@ -156,7 +158,7 @@ func (client TenantAccessGitClient) RegeneratePrimaryKeyPreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -202,13 +204,15 @@ func (client TenantAccessGitClient) RegenerateSecondaryKey(resourceGroupName str req, err := client.RegenerateSecondaryKeyPreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateSecondaryKeySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", resp, "Failure sending request") + return } result, err = client.RegenerateSecondaryKeyResponder(resp) @@ -227,7 +231,7 @@ func (client TenantAccessGitClient) RegenerateSecondaryKeyPreparer(resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/tenantconfiguration.go b/arm/apimanagement/tenantconfiguration.go index f3fc52c9fca7..90aeb4deed8f 100755 --- a/arm/apimanagement/tenantconfiguration.go +++ b/arm/apimanagement/tenantconfiguration.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// TenantConfigurationClient is the use these REST APIs for performing -// operations on entities like API, Product, and Subscription associated with -// your Azure API Management deployment. +// TenantConfigurationClient is the composite Swagger for ApiManagement Client type TenantConfigurationClient struct { ManagementClient } @@ -53,7 +51,9 @@ func NewTenantConfigurationClientWithBaseURI(baseURI string, subscriptionID stri // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. parameters is deploy Configuration // parameters. -func (client TenantConfigurationClient) Deploy(resourceGroupName string, serviceName string, parameters DeployConfigurationParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client TenantConfigurationClient) Deploy(resourceGroupName string, serviceName string, parameters DeployConfigurationParameters, cancel <-chan struct{}) (<-chan OperationResultContract, <-chan error) { + resultChan := make(chan OperationResultContract, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -61,26 +61,40 @@ func (client TenantConfigurationClient) Deploy(resourceGroupName string, service {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Branch", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.TenantConfigurationClient", "Deploy") + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.TenantConfigurationClient", "Deploy") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.DeployPreparer(resourceGroupName, serviceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", nil, "Failure preparing request") - } - - resp, err := client.DeploySender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", resp, "Failure sending request") - } - - result, err = client.DeployResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result OperationResultContract + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeployPreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", nil, "Failure preparing request") + return + } + + resp, err := client.DeploySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", resp, "Failure sending request") + return + } + + result, err = client.DeployResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeployPreparer prepares the Deploy request. @@ -91,7 +105,7 @@ func (client TenantConfigurationClient) DeployPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -116,13 +130,14 @@ func (client TenantConfigurationClient) DeploySender(req *http.Request) (*http.R // DeployResponder handles the response to the Deploy request. The method always // closes the http.Response Body. -func (client TenantConfigurationClient) DeployResponder(resp *http.Response) (result autorest.Response, err error) { +func (client TenantConfigurationClient) DeployResponder(resp *http.Response) (result OperationResultContract, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -135,7 +150,9 @@ func (client TenantConfigurationClient) DeployResponder(resp *http.Response) (re // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. parameters is save Configuration parameters. -func (client TenantConfigurationClient) Save(resourceGroupName string, serviceName string, parameters SaveConfigurationParameter, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client TenantConfigurationClient) Save(resourceGroupName string, serviceName string, parameters SaveConfigurationParameter, cancel <-chan struct{}) (<-chan OperationResultContract, <-chan error) { + resultChan := make(chan OperationResultContract, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -143,26 +160,40 @@ func (client TenantConfigurationClient) Save(resourceGroupName string, serviceNa {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Branch", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.TenantConfigurationClient", "Save") - } - - req, err := client.SavePreparer(resourceGroupName, serviceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", nil, "Failure preparing request") - } - - resp, err := client.SaveSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", resp, "Failure sending request") + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.TenantConfigurationClient", "Save") + close(errChan) + close(resultChan) + return resultChan, errChan } - result, err = client.SaveResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result OperationResultContract + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.SavePreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", nil, "Failure preparing request") + return + } + + resp, err := client.SaveSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", resp, "Failure sending request") + return + } + + result, err = client.SaveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // SavePreparer prepares the Save request. @@ -173,7 +204,7 @@ func (client TenantConfigurationClient) SavePreparer(resourceGroupName string, s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -198,13 +229,14 @@ func (client TenantConfigurationClient) SaveSender(req *http.Request) (*http.Res // SaveResponder handles the response to the Save request. The method always // closes the http.Response Body. -func (client TenantConfigurationClient) SaveResponder(resp *http.Response) (result autorest.Response, err error) { +func (client TenantConfigurationClient) SaveResponder(resp *http.Response) (result OperationResultContract, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -217,7 +249,9 @@ func (client TenantConfigurationClient) SaveResponder(resp *http.Response) (resu // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. parameters is validate Configuration // parameters. -func (client TenantConfigurationClient) Validate(resourceGroupName string, serviceName string, parameters DeployConfigurationParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client TenantConfigurationClient) Validate(resourceGroupName string, serviceName string, parameters DeployConfigurationParameters, cancel <-chan struct{}) (<-chan OperationResultContract, <-chan error) { + resultChan := make(chan OperationResultContract, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -225,26 +259,40 @@ func (client TenantConfigurationClient) Validate(resourceGroupName string, servi {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Branch", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.TenantConfigurationClient", "Validate") - } - - req, err := client.ValidatePreparer(resourceGroupName, serviceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", nil, "Failure preparing request") + errChan <- validation.NewErrorWithValidationError(err, "apimanagement.TenantConfigurationClient", "Validate") + close(errChan) + close(resultChan) + return resultChan, errChan } - resp, err := client.ValidateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", resp, "Failure sending request") - } - - result, err = client.ValidateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result OperationResultContract + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ValidatePreparer(resourceGroupName, serviceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", resp, "Failure sending request") + return + } + + result, err = client.ValidateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ValidatePreparer prepares the Validate request. @@ -255,7 +303,7 @@ func (client TenantConfigurationClient) ValidatePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -280,12 +328,13 @@ func (client TenantConfigurationClient) ValidateSender(req *http.Request) (*http // ValidateResponder handles the response to the Validate request. The method always // closes the http.Response Body. -func (client TenantConfigurationClient) ValidateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client TenantConfigurationClient) ValidateResponder(resp *http.Response) (result OperationResultContract, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/apimanagement/tenantconfigurationsyncstate.go b/arm/apimanagement/tenantconfigurationsyncstate.go index e5967483bc0d..14e36721c457 100755 --- a/arm/apimanagement/tenantconfigurationsyncstate.go +++ b/arm/apimanagement/tenantconfigurationsyncstate.go @@ -25,9 +25,8 @@ import ( "net/http" ) -// TenantConfigurationSyncStateClient is the use these REST APIs for performing -// operations on entities like API, Product, and Subscription associated with -// your Azure API Management deployment. +// TenantConfigurationSyncStateClient is the composite Swagger for +// ApiManagement Client type TenantConfigurationSyncStateClient struct { ManagementClient } @@ -60,13 +59,15 @@ func (client TenantConfigurationSyncStateClient) Get(resourceGroupName string, s req, err := client.GetPreparer(resourceGroupName, serviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSyncStateClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSyncStateClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSyncStateClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSyncStateClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -85,7 +86,7 @@ func (client TenantConfigurationSyncStateClient) GetPreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/tenantpolicy.go b/arm/apimanagement/tenantpolicy.go new file mode 100644 index 000000000000..6bb36d40944e --- /dev/null +++ b/arm/apimanagement/tenantpolicy.go @@ -0,0 +1,272 @@ +package apimanagement + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "io" + "net/http" +) + +// TenantPolicyClient is the composite Swagger for ApiManagement Client +type TenantPolicyClient struct { + ManagementClient +} + +// NewTenantPolicyClient creates an instance of the TenantPolicyClient client. +func NewTenantPolicyClient(subscriptionID string) TenantPolicyClient { + return NewTenantPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTenantPolicyClientWithBaseURI creates an instance of the +// TenantPolicyClient client. +func NewTenantPolicyClientWithBaseURI(baseURI string, subscriptionID string) TenantPolicyClient { + return TenantPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates global policy configuration for the +// tenant. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. parameters is the policy content details. +// parameters will be closed upon successful return. Callers should ensure +// closure when receiving an error.ifMatch is the entity state (Etag) version +// of the tenant policy to update. A value of "*" can be used for If-Match to +// unconditionally apply the operation. +func (client TenantPolicyClient) CreateOrUpdate(resourceGroupName string, serviceName string, parameters io.ReadCloser, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.TenantPolicyClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TenantPolicyClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, parameters io.ReadCloser, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/policy", pathParameters), + autorest.WithFile(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client TenantPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TenantPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete deletes the global tenant policy configuration. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. ifMatch is the entity state (Etag) version of +// the tenant policy to update. A value of "*" can be used for If-Match to +// unconditionally apply the operation. +func (client TenantPolicyClient) Delete(resourceGroupName string, serviceName string, ifMatch string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.TenantPolicyClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, serviceName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client TenantPolicyClient) DeletePreparer(resourceGroupName string, serviceName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/policy", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client TenantPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client TenantPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the global policy configuration of the tenant. +// +// resourceGroupName is the name of the resource group. serviceName is the name +// of the API Management service. +func (client TenantPolicyClient) Get(resourceGroupName string, serviceName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "apimanagement.TenantPolicyClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantPolicyClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TenantPolicyClient) GetPreparer(resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-10-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/policy", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TenantPolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TenantPolicyClient) GetResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/apimanagement/usergroups.go b/arm/apimanagement/usergroups.go index 56c195492510..ccfa56ebb392 100755 --- a/arm/apimanagement/usergroups.go +++ b/arm/apimanagement/usergroups.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// UserGroupsClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// UserGroupsClient is the composite Swagger for ApiManagement Client type UserGroupsClient struct { ManagementClient } @@ -43,7 +41,7 @@ func NewUserGroupsClientWithBaseURI(baseURI string, subscriptionID string) UserG return UserGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// ListByUser lists all user groups. +// ListByUsers lists all user groups. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. uid is user identifier. Must be unique in the @@ -57,7 +55,7 @@ func NewUserGroupsClientWithBaseURI(baseURI string, subscriptionID string) UserG // | description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, // endswith | top is number of records to return. skip is number of records to // skip. -func (client UserGroupsClient) ListByUser(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (result GroupCollection, err error) { +func (client UserGroupsClient) ListByUsers(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (result GroupCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -73,30 +71,32 @@ func (client UserGroupsClient) ListByUser(resourceGroupName string, serviceName {TargetValue: skip, Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.UserGroupsClient", "ListByUser") + return result, validation.NewErrorWithValidationError(err, "apimanagement.UserGroupsClient", "ListByUsers") } - req, err := client.ListByUserPreparer(resourceGroupName, serviceName, uid, filter, top, skip) + req, err := client.ListByUsersPreparer(resourceGroupName, serviceName, uid, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUser", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUsers", nil, "Failure preparing request") + return } - resp, err := client.ListByUserSender(req) + resp, err := client.ListByUsersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUser", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUsers", resp, "Failure sending request") + return } - result, err = client.ListByUserResponder(resp) + result, err = client.ListByUsersResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUser", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUsers", resp, "Failure responding to request") } return } -// ListByUserPreparer prepares the ListByUser request. -func (client UserGroupsClient) ListByUserPreparer(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (*http.Request, error) { +// ListByUsersPreparer prepares the ListByUsers request. +func (client UserGroupsClient) ListByUsersPreparer(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), @@ -104,7 +104,7 @@ func (client UserGroupsClient) ListByUserPreparer(resourceGroupName string, serv "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -126,15 +126,15 @@ func (client UserGroupsClient) ListByUserPreparer(resourceGroupName string, serv return preparer.Prepare(&http.Request{}) } -// ListByUserSender sends the ListByUser request. The method will close the +// ListByUsersSender sends the ListByUsers request. The method will close the // http.Response Body if it receives an error. -func (client UserGroupsClient) ListByUserSender(req *http.Request) (*http.Response, error) { +func (client UserGroupsClient) ListByUsersSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByUserResponder handles the response to the ListByUser request. The method always +// ListByUsersResponder handles the response to the ListByUsers request. The method always // closes the http.Response Body. -func (client UserGroupsClient) ListByUserResponder(resp *http.Response) (result GroupCollection, err error) { +func (client UserGroupsClient) ListByUsersResponder(resp *http.Response) (result GroupCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -145,25 +145,25 @@ func (client UserGroupsClient) ListByUserResponder(resp *http.Response) (result return } -// ListByUserNextResults retrieves the next set of results, if any. -func (client UserGroupsClient) ListByUserNextResults(lastResults GroupCollection) (result GroupCollection, err error) { +// ListByUsersNextResults retrieves the next set of results, if any. +func (client UserGroupsClient) ListByUsersNextResults(lastResults GroupCollection) (result GroupCollection, err error) { req, err := lastResults.GroupCollectionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUser", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUsers", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByUserSender(req) + resp, err := client.ListByUsersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUser", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUsers", resp, "Failure sending next results request") } - result, err = client.ListByUserResponder(resp) + result, err = client.ListByUsersResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUser", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupsClient", "ListByUsers", resp, "Failure responding to next results request") } return diff --git a/arm/apimanagement/useridentities.go b/arm/apimanagement/useridentities.go index 48e8a0894d13..9dc0bd72c72e 100755 --- a/arm/apimanagement/useridentities.go +++ b/arm/apimanagement/useridentities.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// UserIdentitiesClient is the use these REST APIs for performing operations on -// entities like API, Product, and Subscription associated with your Azure API -// Management deployment. +// UserIdentitiesClient is the composite Swagger for ApiManagement Client type UserIdentitiesClient struct { ManagementClient } @@ -44,12 +42,12 @@ func NewUserIdentitiesClientWithBaseURI(baseURI string, subscriptionID string) U return UserIdentitiesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// ListByUser lists all user identities. +// ListByUsers lists all user identities. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. uid is user identifier. Must be unique in the // current API Management service instance. -func (client UserIdentitiesClient) ListByUser(resourceGroupName string, serviceName string, uid string) (result ListUserIdentityContract, err error) { +func (client UserIdentitiesClient) ListByUsers(resourceGroupName string, serviceName string, uid string) (result UserIdentityCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -59,30 +57,32 @@ func (client UserIdentitiesClient) ListByUser(resourceGroupName string, serviceN Constraints: []validation.Constraint{{Target: "uid", Name: validation.MaxLength, Rule: 256, Chain: nil}, {Target: "uid", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "uid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.UserIdentitiesClient", "ListByUser") + return result, validation.NewErrorWithValidationError(err, "apimanagement.UserIdentitiesClient", "ListByUsers") } - req, err := client.ListByUserPreparer(resourceGroupName, serviceName, uid) + req, err := client.ListByUsersPreparer(resourceGroupName, serviceName, uid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "ListByUser", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "ListByUsers", nil, "Failure preparing request") + return } - resp, err := client.ListByUserSender(req) + resp, err := client.ListByUsersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "ListByUser", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "ListByUsers", resp, "Failure sending request") + return } - result, err = client.ListByUserResponder(resp) + result, err = client.ListByUsersResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "ListByUser", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "ListByUsers", resp, "Failure responding to request") } return } -// ListByUserPreparer prepares the ListByUser request. -func (client UserIdentitiesClient) ListByUserPreparer(resourceGroupName string, serviceName string, uid string) (*http.Request, error) { +// ListByUsersPreparer prepares the ListByUsers request. +func (client UserIdentitiesClient) ListByUsersPreparer(resourceGroupName string, serviceName string, uid string) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), @@ -90,7 +90,7 @@ func (client UserIdentitiesClient) ListByUserPreparer(resourceGroupName string, "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -103,20 +103,20 @@ func (client UserIdentitiesClient) ListByUserPreparer(resourceGroupName string, return preparer.Prepare(&http.Request{}) } -// ListByUserSender sends the ListByUser request. The method will close the +// ListByUsersSender sends the ListByUsers request. The method will close the // http.Response Body if it receives an error. -func (client UserIdentitiesClient) ListByUserSender(req *http.Request) (*http.Response, error) { +func (client UserIdentitiesClient) ListByUsersSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByUserResponder handles the response to the ListByUser request. The method always +// ListByUsersResponder handles the response to the ListByUsers request. The method always // closes the http.Response Body. -func (client UserIdentitiesClient) ListByUserResponder(resp *http.Response) (result ListUserIdentityContract, err error) { +func (client UserIdentitiesClient) ListByUsersResponder(resp *http.Response) (result UserIdentityCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return diff --git a/arm/apimanagement/users.go b/arm/apimanagement/users.go index 4982d1499188..91efd90ef514 100755 --- a/arm/apimanagement/users.go +++ b/arm/apimanagement/users.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// UsersClient is the use these REST APIs for performing operations on entities -// like API, Product, and Subscription associated with your Azure API -// Management deployment. +// UsersClient is the composite Swagger for ApiManagement Client type UsersClient struct { ManagementClient } @@ -77,13 +75,15 @@ func (client UsersClient) CreateOrUpdate(resourceGroupName string, serviceName s req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, uid, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -103,7 +103,7 @@ func (client UsersClient) CreateOrUpdatePreparer(resourceGroupName string, servi "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -159,13 +159,15 @@ func (client UsersClient) Delete(resourceGroupName string, serviceName string, u req, err := client.DeletePreparer(resourceGroupName, serviceName, uid, ifMatch, deleteSubscriptions) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -185,7 +187,7 @@ func (client UsersClient) DeletePreparer(resourceGroupName string, serviceName s "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -242,13 +244,15 @@ func (client UsersClient) GenerateSsoURL(resourceGroupName string, serviceName s req, err := client.GenerateSsoURLPreparer(resourceGroupName, serviceName, uid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "GenerateSsoURL", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "GenerateSsoURL", nil, "Failure preparing request") + return } resp, err := client.GenerateSsoURLSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "GenerateSsoURL", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "GenerateSsoURL", resp, "Failure sending request") + return } result, err = client.GenerateSsoURLResponder(resp) @@ -268,7 +272,7 @@ func (client UsersClient) GenerateSsoURLPreparer(resourceGroupName string, servi "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -320,13 +324,15 @@ func (client UsersClient) Get(resourceGroupName string, serviceName string, uid req, err := client.GetPreparer(resourceGroupName, serviceName, uid) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -346,7 +352,7 @@ func (client UsersClient) GetPreparer(resourceGroupName string, serviceName stri "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -417,13 +423,15 @@ func (client UsersClient) ListByService(resourceGroupName string, serviceName st req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "ListByService", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "ListByService", nil, "Failure preparing request") + return } resp, err := client.ListByServiceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "ListByService", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "ListByService", resp, "Failure sending request") + return } result, err = client.ListByServiceResponder(resp) @@ -442,7 +450,7 @@ func (client UsersClient) ListByServicePreparer(resourceGroupName string, servic "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -529,13 +537,15 @@ func (client UsersClient) Update(resourceGroupName string, serviceName string, u req, err := client.UpdatePreparer(resourceGroupName, serviceName, uid, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UsersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -555,7 +565,7 @@ func (client UsersClient) UpdatePreparer(resourceGroupName string, serviceName s "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/apimanagement/usersubscriptions.go b/arm/apimanagement/usersubscriptions.go index 32dd2e351ed7..162e7b1f9342 100755 --- a/arm/apimanagement/usersubscriptions.go +++ b/arm/apimanagement/usersubscriptions.go @@ -25,9 +25,7 @@ import ( "net/http" ) -// UserSubscriptionsClient is the use these REST APIs for performing operations -// on entities like API, Product, and Subscription associated with your Azure -// API Management deployment. +// UserSubscriptionsClient is the composite Swagger for ApiManagement Client type UserSubscriptionsClient struct { ManagementClient } @@ -44,7 +42,7 @@ func NewUserSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string return UserSubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// ListByUser lists the collection of subscriptions of the specified user. +// ListByUsers lists the collection of subscriptions of the specified user. // // resourceGroupName is the name of the resource group. serviceName is the name // of the API Management service. uid is user identifier. Must be unique in the @@ -63,7 +61,7 @@ func NewUserSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string // endswith | // | state | eq | // | top is number of records to return. skip is number of records to skip. -func (client UserSubscriptionsClient) ListByUser(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (result SubscriptionCollection, err error) { +func (client UserSubscriptionsClient) ListByUsers(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (result SubscriptionCollection, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: serviceName, Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, @@ -79,30 +77,32 @@ func (client UserSubscriptionsClient) ListByUser(resourceGroupName string, servi {TargetValue: skip, Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "apimanagement.UserSubscriptionsClient", "ListByUser") + return result, validation.NewErrorWithValidationError(err, "apimanagement.UserSubscriptionsClient", "ListByUsers") } - req, err := client.ListByUserPreparer(resourceGroupName, serviceName, uid, filter, top, skip) + req, err := client.ListByUsersPreparer(resourceGroupName, serviceName, uid, filter, top, skip) if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUser", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUsers", nil, "Failure preparing request") + return } - resp, err := client.ListByUserSender(req) + resp, err := client.ListByUsersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUser", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUsers", resp, "Failure sending request") + return } - result, err = client.ListByUserResponder(resp) + result, err = client.ListByUsersResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUser", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUsers", resp, "Failure responding to request") } return } -// ListByUserPreparer prepares the ListByUser request. -func (client UserSubscriptionsClient) ListByUserPreparer(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (*http.Request, error) { +// ListByUsersPreparer prepares the ListByUsers request. +func (client UserSubscriptionsClient) ListByUsersPreparer(resourceGroupName string, serviceName string, uid string, filter string, top *int32, skip *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "serviceName": autorest.Encode("path", serviceName), @@ -110,7 +110,7 @@ func (client UserSubscriptionsClient) ListByUserPreparer(resourceGroupName strin "uid": autorest.Encode("path", uid), } - const APIVersion = "2016-07-07" + const APIVersion = "2016-10-10" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -132,15 +132,15 @@ func (client UserSubscriptionsClient) ListByUserPreparer(resourceGroupName strin return preparer.Prepare(&http.Request{}) } -// ListByUserSender sends the ListByUser request. The method will close the +// ListByUsersSender sends the ListByUsers request. The method will close the // http.Response Body if it receives an error. -func (client UserSubscriptionsClient) ListByUserSender(req *http.Request) (*http.Response, error) { +func (client UserSubscriptionsClient) ListByUsersSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByUserResponder handles the response to the ListByUser request. The method always +// ListByUsersResponder handles the response to the ListByUsers request. The method always // closes the http.Response Body. -func (client UserSubscriptionsClient) ListByUserResponder(resp *http.Response) (result SubscriptionCollection, err error) { +func (client UserSubscriptionsClient) ListByUsersResponder(resp *http.Response) (result SubscriptionCollection, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -151,25 +151,25 @@ func (client UserSubscriptionsClient) ListByUserResponder(resp *http.Response) ( return } -// ListByUserNextResults retrieves the next set of results, if any. -func (client UserSubscriptionsClient) ListByUserNextResults(lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { +// ListByUsersNextResults retrieves the next set of results, if any. +func (client UserSubscriptionsClient) ListByUsersNextResults(lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { req, err := lastResults.SubscriptionCollectionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUser", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUsers", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByUserSender(req) + resp, err := client.ListByUsersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUser", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUsers", resp, "Failure sending next results request") } - result, err = client.ListByUserResponder(resp) + result, err = client.ListByUsersResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUser", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionsClient", "ListByUsers", resp, "Failure responding to next results request") } return diff --git a/arm/apimanagement/version.go b/arm/apimanagement/version.go index 033384a24290..727e03a3d1c8 100755 --- a/arm/apimanagement/version.go +++ b/arm/apimanagement/version.go @@ -20,10 +20,10 @@ package apimanagement // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-apimanagement/2016-07-07" + return "Azure-SDK-For-Go/v10.0.0-beta arm-apimanagement/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/appinsights/client.go b/arm/appinsights/client.go new file mode 100644 index 000000000000..e00640451a69 --- /dev/null +++ b/arm/appinsights/client.go @@ -0,0 +1,53 @@ +// Package appinsights implements the Azure ARM Appinsights service API version +// . +// +// Composite Swagger for Application Insights Management Client +package appinsights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Appinsights + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Appinsights. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/arm/appinsights/components.go b/arm/appinsights/components.go new file mode 100644 index 000000000000..45c5c8282a56 --- /dev/null +++ b/arm/appinsights/components.go @@ -0,0 +1,497 @@ +package appinsights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ComponentsClient is the composite Swagger for Application Insights +// Management Client +type ComponentsClient struct { + ManagementClient +} + +// NewComponentsClient creates an instance of the ComponentsClient client. +func NewComponentsClient(subscriptionID string) ComponentsClient { + return NewComponentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewComponentsClientWithBaseURI creates an instance of the ComponentsClient +// client. +func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string) ComponentsClient { + return ComponentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates (or updates) an Application Insights component. Note: +// You cannot specify a different value for InstrumentationKey nor AppId in the +// Put operation. +// +// resourceGroupName is the name of the resource group. resourceName is the +// name of the Application Insights component resource. insightProperties is +// properties that need to be specified to create an Application Insights +// component. +func (client ComponentsClient) CreateOrUpdate(resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (result ApplicationInsightsComponent, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: insightProperties, + Constraints: []validation.Constraint{{Target: "insightProperties.Kind", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "appinsights.ComponentsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceName, insightProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ComponentsClient) CreateOrUpdatePreparer(resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), + autorest.WithJSON(insightProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ComponentsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the +// name of the Application Insights component resource. +func (client ComponentsClient) Delete(resourceGroupName string, resourceName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ComponentsClient) DeletePreparer(resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ComponentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the +// name of the Application Insights component resource. +func (client ComponentsClient) Get(resourceGroupName string, resourceName string) (result ApplicationInsightsComponent, err error) { + req, err := client.GetPreparer(resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComponentsClient) GetPreparer(resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComponentsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all Application Insights components within a +// subscription. +func (client ComponentsClient) List() (result ApplicationInsightsComponentListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ComponentsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/components", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ComponentsClient) ListResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ComponentsClient) ListNextResults(lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) { + req, err := lastResults.ApplicationInsightsComponentListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup gets a list of Application Insights components within a +// resource group. +// +// resourceGroupName is the name of the resource group. +func (client ComponentsClient) ListByResourceGroup(resourceGroupName string) (result ApplicationInsightsComponentListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ComponentsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ComponentsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client ComponentsClient) ListByResourceGroupNextResults(lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) { + req, err := lastResults.ApplicationInsightsComponentListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// UpdateTags updates an existing component's tags. To update other fields use +// the CreateOrUpdate method. +// +// resourceGroupName is the name of the resource group. resourceName is the +// name of the Application Insights component resource. componentTags is +// updated tag information to set into the component instance. +func (client ComponentsClient) UpdateTags(resourceGroupName string, resourceName string, componentTags TagsResource) (result ApplicationInsightsComponent, err error) { + req, err := client.UpdateTagsPreparer(resourceGroupName, resourceName, componentTags) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "UpdateTags", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "UpdateTags", resp, "Failure sending request") + return + } + + result, err = client.UpdateTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.ComponentsClient", "UpdateTags", resp, "Failure responding to request") + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client ComponentsClient) UpdateTagsPreparer(resourceGroupName string, resourceName string, componentTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), + autorest.WithJSON(componentTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client ComponentsClient) UpdateTagsResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/appinsights/models.go b/arm/appinsights/models.go new file mode 100644 index 000000000000..0cf0bb0ad08e --- /dev/null +++ b/arm/appinsights/models.go @@ -0,0 +1,226 @@ +package appinsights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// ApplicationType enumerates the values for application type. +type ApplicationType string + +const ( + // Other specifies the other state for application type. + Other ApplicationType = "other" + // Web specifies the web state for application type. + Web ApplicationType = "web" +) + +// FlowType enumerates the values for flow type. +type FlowType string + +const ( + // Bluefield specifies the bluefield state for flow type. + Bluefield FlowType = "Bluefield" +) + +// RequestSource enumerates the values for request source. +type RequestSource string + +const ( + // Rest specifies the rest state for request source. + Rest RequestSource = "rest" +) + +// WebTestKind enumerates the values for web test kind. +type WebTestKind string + +const ( + // Multistep specifies the multistep state for web test kind. + Multistep WebTestKind = "multistep" + // Ping specifies the ping state for web test kind. + Ping WebTestKind = "ping" +) + +// ApplicationInsightsComponent is an Application Insights component +// definition. +type ApplicationInsightsComponent struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Kind *string `json:"kind,omitempty"` + *ApplicationInsightsComponentProperties `json:"properties,omitempty"` +} + +// ApplicationInsightsComponentListResult is describes the list of Application +// Insights Resources. +type ApplicationInsightsComponentListResult struct { + autorest.Response `json:"-"` + Value *[]ApplicationInsightsComponent `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplicationInsightsComponentListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ApplicationInsightsComponentListResult) ApplicationInsightsComponentListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ApplicationInsightsComponentProperties is properties that define an +// Application Insights component resource. +type ApplicationInsightsComponentProperties struct { + ApplicationID *string `json:"ApplicationId,omitempty"` + AppID *string `json:"AppId,omitempty"` + ApplicationType ApplicationType `json:"Application_Type,omitempty"` + FlowType FlowType `json:"Flow_Type,omitempty"` + RequestSource RequestSource `json:"Request_Source,omitempty"` + InstrumentationKey *string `json:"InstrumentationKey,omitempty"` + CreationDate *date.Time `json:"CreationDate,omitempty"` + TenantID *string `json:"TenantId,omitempty"` + HockeyAppID *string `json:"HockeyAppId,omitempty"` + HockeyAppToken *string `json:"HockeyAppToken,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + SamplingPercentage *float64 `json:"SamplingPercentage,omitempty"` +} + +// ErrorResponse is error reponse indicates Insights service is not able to +// process the incoming request. The reason is provided in the error message. +type ErrorResponse struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// Operation is cDN REST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is the object that represents the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult is result of the request to list CDN operations. It +// contains a list of operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// Resource is an azure resource object +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// TagsResource is a container holding only the Tags for a resource, allowing +// the user to update the tags on a WebTest instance. +type TagsResource struct { + Tags *map[string]*string `json:"tags,omitempty"` +} + +// WebTest is an Application Insights web test definition. +type WebTest struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Kind WebTestKind `json:"kind,omitempty"` + *WebTestProperties `json:"properties,omitempty"` +} + +// WebTestGeolocation is geo-physical location to run a web test from. You must +// specify one or more locations for the test to run from. +type WebTestGeolocation struct { + Location *string `json:"Id,omitempty"` +} + +// WebTestListResult is a list of 0 or more Application Insights web test +// definitions. +type WebTestListResult struct { + autorest.Response `json:"-"` + Value *[]WebTest `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// WebTestListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client WebTestListResult) WebTestListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// WebTestProperties is metadata describing a web test for an Azure resource. +type WebTestProperties struct { + SyntheticMonitorID *string `json:"SyntheticMonitorId,omitempty"` + WebTestName *string `json:"Name,omitempty"` + Description *string `json:"Description,omitempty"` + Enabled *bool `json:"Enabled,omitempty"` + Frequency *int32 `json:"Frequency,omitempty"` + Timeout *int32 `json:"Timeout,omitempty"` + WebTestKind WebTestKind `json:"Kind,omitempty"` + RetryEnabled *bool `json:"RetryEnabled,omitempty"` + Locations *[]WebTestGeolocation `json:"Locations,omitempty"` + Configuration *WebTestPropertiesConfiguration `json:"Configuration,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// WebTestPropertiesConfiguration is an XML configuration specification for a +// WebTest. +type WebTestPropertiesConfiguration struct { + WebTest *string `json:"WebTest,omitempty"` +} diff --git a/arm/appinsights/operations.go b/arm/appinsights/operations.go new file mode 100644 index 000000000000..37e9fd47c843 --- /dev/null +++ b/arm/appinsights/operations.go @@ -0,0 +1,123 @@ +package appinsights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the composite Swagger for Application Insights +// Management Client +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available insights REST API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "appinsights.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appinsights.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/appinsights/version.go b/arm/appinsights/version.go new file mode 100644 index 000000000000..6694e98b5238 --- /dev/null +++ b/arm/appinsights/version.go @@ -0,0 +1,29 @@ +package appinsights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.0.0-beta arm-appinsights/" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.0.0-beta" +} diff --git a/arm/appinsights/webtests.go b/arm/appinsights/webtests.go new file mode 100644 index 000000000000..509dfe804c65 --- /dev/null +++ b/arm/appinsights/webtests.go @@ -0,0 +1,499 @@ +package appinsights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// WebTestsClient is the composite Swagger for Application Insights Management +// Client +type WebTestsClient struct { + ManagementClient +} + +// NewWebTestsClient creates an instance of the WebTestsClient client. +func NewWebTestsClient(subscriptionID string) WebTestsClient { + return NewWebTestsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWebTestsClientWithBaseURI creates an instance of the WebTestsClient +// client. +func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { + return WebTestsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an Application Insights web test +// definition. +// +// resourceGroupName is the name of the resource group. webTestName is the name +// of the Application Insights webtest resource. webTestDefinition is +// properties that need to be specified to create or update an Application +// Insights web test definition. +func (client WebTestsClient) CreateOrUpdate(resourceGroupName string, webTestName string, webTestDefinition WebTest) (result WebTest, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: webTestDefinition, + Constraints: []validation.Constraint{{Target: "webTestDefinition.WebTestProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "webTestDefinition.WebTestProperties.SyntheticMonitorID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "webTestDefinition.WebTestProperties.WebTestName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "webTestDefinition.WebTestProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "appinsights.WebTestsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, webTestName, webTestDefinition) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WebTestsClient) CreateOrUpdatePreparer(resourceGroupName string, webTestName string, webTestDefinition WebTest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), + autorest.WithJSON(webTestDefinition), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WebTestsClient) CreateOrUpdateResponder(resp *http.Response) (result WebTest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an Application Insights web test. +// +// resourceGroupName is the name of the resource group. webTestName is the name +// of the Application Insights webtest resource. +func (client WebTestsClient) Delete(resourceGroupName string, webTestName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, webTestName) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WebTestsClient) DeletePreparer(resourceGroupName string, webTestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WebTestsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a specific Application Insights web test definition. +// +// resourceGroupName is the name of the resource group. webTestName is the name +// of the Application Insights webtest resource. +func (client WebTestsClient) Get(resourceGroupName string, webTestName string) (result WebTest, err error) { + req, err := client.GetPreparer(resourceGroupName, webTestName) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WebTestsClient) GetPreparer(resourceGroupName string, webTestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WebTestsClient) GetResponder(resp *http.Response) (result WebTest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all Application Insights web test alerts definitioned within a +// subscription. +func (client WebTestsClient) List() (result WebTestListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client WebTestsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/webtests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WebTestsClient) ListResponder(resp *http.Response) (result WebTestListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client WebTestsClient) ListNextResults(lastResults WebTestListResult) (result WebTestListResult, err error) { + req, err := lastResults.WebTestListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup get all Application Insights web tests defined within a +// specified resource group. +// +// resourceGroupName is the name of the resource group. +func (client WebTestsClient) ListByResourceGroup(resourceGroupName string) (result WebTestListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client WebTestsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client WebTestsClient) ListByResourceGroupResponder(resp *http.Response) (result WebTestListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client WebTestsClient) ListByResourceGroupNextResults(lastResults WebTestListResult) (result WebTestListResult, err error) { + req, err := lastResults.WebTestListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// UpdateTags creates or updates an Application Insights web test definition. +// +// resourceGroupName is the name of the resource group. webTestName is the name +// of the Application Insights webtest resource. webTestTags is updated tag +// information to set into the web test instance. +func (client WebTestsClient) UpdateTags(resourceGroupName string, webTestName string, webTestTags TagsResource) (result WebTest, err error) { + req, err := client.UpdateTagsPreparer(resourceGroupName, webTestName, webTestTags) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "UpdateTags", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "UpdateTags", resp, "Failure sending request") + return + } + + result, err = client.UpdateTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appinsights.WebTestsClient", "UpdateTags", resp, "Failure responding to request") + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client WebTestsClient) UpdateTagsPreparer(resourceGroupName string, webTestName string, webTestTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), + autorest.WithJSON(webTestTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client WebTestsClient) UpdateTagsResponder(resp *http.Response) (result WebTest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/authorization/classicadministrators.go b/arm/authorization/classicadministrators.go index 1258a9d4b18e..50824a38a3dc 100755 --- a/arm/authorization/classicadministrators.go +++ b/arm/authorization/classicadministrators.go @@ -51,13 +51,15 @@ func NewClassicAdministratorsClientWithBaseURI(baseURI string, subscriptionID st func (client ClassicAdministratorsClient) List() (result ClassicAdministratorListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/authorization/permissions.go b/arm/authorization/permissions.go index e63715acb574..36abbb9c2c94 100755 --- a/arm/authorization/permissions.go +++ b/arm/authorization/permissions.go @@ -55,13 +55,15 @@ func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) Perm func (client PermissionsClient) ListForResource(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResult, err error) { req, err := client.ListForResourcePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", nil, "Failure preparing request") + return } resp, err := client.ListForResourceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure sending request") + return } result, err = client.ListForResourceResponder(resp) @@ -147,13 +149,15 @@ func (client PermissionsClient) ListForResourceNextResults(lastResults Permissio func (client PermissionsClient) ListForResourceGroup(resourceGroupName string) (result PermissionGetResult, err error) { req, err := client.ListForResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListForResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure sending request") + return } result, err = client.ListForResourceGroupResponder(resp) diff --git a/arm/authorization/provideroperationsmetadata.go b/arm/authorization/provideroperationsmetadata.go index 798a573896b2..5208637b55fe 100755 --- a/arm/authorization/provideroperationsmetadata.go +++ b/arm/authorization/provideroperationsmetadata.go @@ -53,13 +53,15 @@ func NewProviderOperationsMetadataClientWithBaseURI(baseURI string, subscription func (client ProviderOperationsMetadataClient) Get(resourceProviderNamespace string, expand string) (result ProviderOperationsMetadata, err error) { req, err := client.GetPreparer(resourceProviderNamespace, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -117,13 +119,15 @@ func (client ProviderOperationsMetadataClient) GetResponder(resp *http.Response) func (client ProviderOperationsMetadataClient) List(expand string) (result ProviderOperationsMetadataListResult, err error) { req, err := client.ListPreparer(expand) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/authorization/roleassignments.go b/arm/authorization/roleassignments.go index 728b71cffd27..6f02c9550dac 100755 --- a/arm/authorization/roleassignments.go +++ b/arm/authorization/roleassignments.go @@ -60,13 +60,15 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) func (client RoleAssignmentsClient) Create(scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { req, err := client.CreatePreparer(scope, roleAssignmentName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -125,13 +127,15 @@ func (client RoleAssignmentsClient) CreateResponder(resp *http.Response) (result func (client RoleAssignmentsClient) CreateByID(roleAssignmentID string, parameters RoleAssignmentCreateParameters) (result RoleAssignment, err error) { req, err := client.CreateByIDPreparer(roleAssignmentID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", nil, "Failure preparing request") + return } resp, err := client.CreateByIDSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "CreateByID", resp, "Failure sending request") + return } result, err = client.CreateByIDResponder(resp) @@ -189,13 +193,15 @@ func (client RoleAssignmentsClient) CreateByIDResponder(resp *http.Response) (re func (client RoleAssignmentsClient) Delete(scope string, roleAssignmentName string) (result RoleAssignment, err error) { req, err := client.DeletePreparer(scope, roleAssignmentName) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -251,13 +257,15 @@ func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result func (client RoleAssignmentsClient) DeleteByID(roleAssignmentID string) (result RoleAssignment, err error) { req, err := client.DeleteByIDPreparer(roleAssignmentID) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", nil, "Failure preparing request") + return } resp, err := client.DeleteByIDSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "DeleteByID", resp, "Failure sending request") + return } result, err = client.DeleteByIDResponder(resp) @@ -313,13 +321,15 @@ func (client RoleAssignmentsClient) DeleteByIDResponder(resp *http.Response) (re func (client RoleAssignmentsClient) Get(scope string, roleAssignmentName string) (result RoleAssignment, err error) { req, err := client.GetPreparer(scope, roleAssignmentName) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -375,13 +385,15 @@ func (client RoleAssignmentsClient) GetResponder(resp *http.Response) (result Ro func (client RoleAssignmentsClient) GetByID(roleAssignmentID string) (result RoleAssignment, err error) { req, err := client.GetByIDPreparer(roleAssignmentID) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", nil, "Failure preparing request") + return } resp, err := client.GetByIDSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "GetByID", resp, "Failure sending request") + return } result, err = client.GetByIDResponder(resp) @@ -439,13 +451,15 @@ func (client RoleAssignmentsClient) GetByIDResponder(resp *http.Response) (resul func (client RoleAssignmentsClient) List(filter string) (result RoleAssignmentListResult, err error) { req, err := client.ListPreparer(filter) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -534,13 +548,15 @@ func (client RoleAssignmentsClient) ListNextResults(lastResults RoleAssignmentLi func (client RoleAssignmentsClient) ListForResource(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result RoleAssignmentListResult, err error) { req, err := client.ListForResourcePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", nil, "Failure preparing request") + return } resp, err := client.ListForResourceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResource", resp, "Failure sending request") + return } result, err = client.ListForResourceResponder(resp) @@ -573,7 +589,7 @@ func (client RoleAssignmentsClient) ListForResourcePreparer(resourceGroupName st preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}providers/Microsoft.Authorization/roleAssignments", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } @@ -630,13 +646,15 @@ func (client RoleAssignmentsClient) ListForResourceNextResults(lastResults RoleA func (client RoleAssignmentsClient) ListForResourceGroup(resourceGroupName string, filter string) (result RoleAssignmentListResult, err error) { req, err := client.ListForResourceGroupPreparer(resourceGroupName, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListForResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForResourceGroup", resp, "Failure sending request") + return } result, err = client.ListForResourceGroupResponder(resp) @@ -722,13 +740,15 @@ func (client RoleAssignmentsClient) ListForResourceGroupNextResults(lastResults func (client RoleAssignmentsClient) ListForScope(scope string, filter string) (result RoleAssignmentListResult, err error) { req, err := client.ListForScopePreparer(scope, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", nil, "Failure preparing request") + return } resp, err := client.ListForScopeSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleAssignmentsClient", "ListForScope", resp, "Failure sending request") + return } result, err = client.ListForScopeResponder(resp) diff --git a/arm/authorization/roledefinitions.go b/arm/authorization/roledefinitions.go index 28dcdd04d04c..cdd9efc22a1d 100755 --- a/arm/authorization/roledefinitions.go +++ b/arm/authorization/roledefinitions.go @@ -53,13 +53,15 @@ func NewRoleDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) func (client RoleDefinitionsClient) CreateOrUpdate(scope string, roleDefinitionID string, roleDefinition RoleDefinition) (result RoleDefinition, err error) { req, err := client.CreateOrUpdatePreparer(scope, roleDefinitionID, roleDefinition) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -118,13 +120,15 @@ func (client RoleDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) func (client RoleDefinitionsClient) Delete(scope string, roleDefinitionID string) (result RoleDefinition, err error) { req, err := client.DeletePreparer(scope, roleDefinitionID) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -181,13 +185,15 @@ func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result func (client RoleDefinitionsClient) Get(scope string, roleDefinitionID string) (result RoleDefinition, err error) { req, err := client.GetPreparer(scope, roleDefinitionID) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -243,13 +249,15 @@ func (client RoleDefinitionsClient) GetResponder(resp *http.Response) (result Ro func (client RoleDefinitionsClient) GetByID(roleDefinitionID string) (result RoleDefinition, err error) { req, err := client.GetByIDPreparer(roleDefinitionID) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", nil, "Failure preparing request") + return } resp, err := client.GetByIDSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure sending request") + return } result, err = client.GetByIDResponder(resp) @@ -306,13 +314,15 @@ func (client RoleDefinitionsClient) GetByIDResponder(resp *http.Response) (resul func (client RoleDefinitionsClient) List(scope string, filter string) (result RoleDefinitionListResult, err error) { req, err := client.ListPreparer(scope, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/authorization/version.go b/arm/authorization/version.go index 3e16099cdc2f..a7287b84eeab 100755 --- a/arm/authorization/version.go +++ b/arm/authorization/version.go @@ -20,10 +20,10 @@ package authorization // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-authorization/2015-07-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-authorization/2015-07-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/automation/account.go b/arm/automation/account.go new file mode 100644 index 000000000000..e651973d5fa6 --- /dev/null +++ b/arm/automation/account.go @@ -0,0 +1,514 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AccountClient is the composite Swagger json for Azure Automation Client +type AccountClient struct { + ManagementClient +} + +// NewAccountClient creates an instance of the AccountClient client. +func NewAccountClient(subscriptionID string) AccountClient { + return NewAccountClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountClientWithBaseURI creates an instance of the AccountClient client. +func NewAccountClientWithBaseURI(baseURI string, subscriptionID string) AccountClient { + return AccountClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update automation account. +// +// resourceGroupName is the resource group name. automationAccountName is +// parameters supplied to the create or update automation account. parameters +// is parameters supplied to the create or update automation account. +func (client AccountClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AccountClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, parameters AccountCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AccountClient) CreateOrUpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an automation account. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. +func (client AccountClient) Delete(resourceGroupName string, automationAccountName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountClient) DeletePreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccountClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get information about an Automation Account. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client AccountClient) Get(resourceGroupName string, automationAccountName string) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountClient) GetPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccountClient) GetResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List retrieve a list of accounts within a given subscription. +func (client AccountClient) List() (result AccountListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccountClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client AccountClient) ListNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.AccountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup retrieve a list of accounts within a given resource +// group. +// +// resourceGroupName is the resource group name. +func (client AccountClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "ListByResourceGroup") + } + + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AccountClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AccountClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client AccountClient) ListByResourceGroupNextResults(lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.AccountListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// Update update an automation account. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. parameters is parameters supplied to the update +// automation account. +func (client AccountClient) Update(resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (result Account, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AccountClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AccountClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountClient) UpdatePreparer(resourceGroupName string, automationAccountName string, parameters AccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AccountClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountClient) UpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/activity.go b/arm/automation/activity.go new file mode 100644 index 000000000000..a103e55443b1 --- /dev/null +++ b/arm/automation/activity.go @@ -0,0 +1,216 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ActivityClient is the composite Swagger json for Azure Automation Client +type ActivityClient struct { + ManagementClient +} + +// NewActivityClient creates an instance of the ActivityClient client. +func NewActivityClient(subscriptionID string) ActivityClient { + return NewActivityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActivityClientWithBaseURI creates an instance of the ActivityClient +// client. +func NewActivityClientWithBaseURI(baseURI string, subscriptionID string) ActivityClient { + return ActivityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the activity in the module identified by module name and +// activity name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. activityName is +// the name of activity. +func (client ActivityClient) Get(resourceGroupName string, automationAccountName string, moduleName string, activityName string) (result Activity, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ActivityClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, moduleName, activityName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActivityClient) GetPreparer(resourceGroupName string, automationAccountName string, moduleName string, activityName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityName": autorest.Encode("path", activityName), + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActivityClient) GetResponder(resp *http.Response) (result Activity, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByModule retrieve a list of activities in the module identified by +// module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. +func (client ActivityClient) ListByModule(resourceGroupName string, automationAccountName string, moduleName string) (result ActivityListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ActivityClient", "ListByModule") + } + + req, err := client.ListByModulePreparer(resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByModuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure sending request") + return + } + + result, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure responding to request") + } + + return +} + +// ListByModulePreparer prepares the ListByModule request. +func (client ActivityClient) ListByModulePreparer(resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByModuleSender sends the ListByModule request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityClient) ListByModuleSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByModuleResponder handles the response to the ListByModule request. The method always +// closes the http.Response Body. +func (client ActivityClient) ListByModuleResponder(resp *http.Response) (result ActivityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByModuleNextResults retrieves the next set of results, if any. +func (client ActivityClient) ListByModuleNextResults(lastResults ActivityListResult) (result ActivityListResult, err error) { + req, err := lastResults.ActivityListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByModuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure sending next results request") + } + + result, err = client.ListByModuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ActivityClient", "ListByModule", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/agentregistrationinformation.go b/arm/automation/agentregistrationinformation.go new file mode 100644 index 000000000000..02d16325ca5b --- /dev/null +++ b/arm/automation/agentregistrationinformation.go @@ -0,0 +1,191 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AgentRegistrationInformationClient is the composite Swagger json for Azure +// Automation Client +type AgentRegistrationInformationClient struct { + ManagementClient +} + +// NewAgentRegistrationInformationClient creates an instance of the +// AgentRegistrationInformationClient client. +func NewAgentRegistrationInformationClient(subscriptionID string) AgentRegistrationInformationClient { + return NewAgentRegistrationInformationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAgentRegistrationInformationClientWithBaseURI creates an instance of the +// AgentRegistrationInformationClient client. +func NewAgentRegistrationInformationClientWithBaseURI(baseURI string, subscriptionID string) AgentRegistrationInformationClient { + return AgentRegistrationInformationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the automation agent registration information. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client AgentRegistrationInformationClient) Get(resourceGroupName string, automationAccountName string) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AgentRegistrationInformationClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AgentRegistrationInformationClient) GetPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) GetResponder(resp *http.Response) (result AgentRegistration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerate a primary or secondary agent registration key +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. parameters is the name of the agent registration +// key to be regenerated +func (client AgentRegistrationInformationClient) RegenerateKey(resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (result AgentRegistration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey") + } + + req, err := client.RegenerateKeyPreparer(resourceGroupName, automationAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.AgentRegistrationInformationClient", "RegenerateKey", resp, "Failure responding to request") + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client AgentRegistrationInformationClient) RegenerateKeyPreparer(resourceGroupName string, automationAccountName string, parameters AgentRegistrationRegenerateKeyParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client AgentRegistrationInformationClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client AgentRegistrationInformationClient) RegenerateKeyResponder(resp *http.Response) (result AgentRegistration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/certificate.go b/arm/automation/certificate.go new file mode 100644 index 000000000000..368c73d49f9e --- /dev/null +++ b/arm/automation/certificate.go @@ -0,0 +1,441 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CertificateClient is the composite Swagger json for Azure Automation Client +type CertificateClient struct { + ManagementClient +} + +// NewCertificateClient creates an instance of the CertificateClient client. +func NewCertificateClient(subscriptionID string) CertificateClient { + return NewCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCertificateClientWithBaseURI creates an instance of the CertificateClient +// client. +func NewCertificateClientWithBaseURI(baseURI string, subscriptionID string) CertificateClient { + return CertificateClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a certificate. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the parameters supplied to the +// create or update certificate operation. parameters is the parameters +// supplied to the create or update certificate operation. +func (client CertificateClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CertificateCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CertificateCreateOrUpdateProperties.Base64Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CertificateClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CertificateClient) CreateOrUpdateResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the certificate. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the name of certificate. +func (client CertificateClient) Delete(resourceGroupName string, automationAccountName string, certificateName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CertificateClient) DeletePreparer(resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the certificate identified by certificate name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the name of certificate. +func (client CertificateClient) Get(resourceGroupName string, automationAccountName string, certificateName string) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CertificateClient) GetPreparer(resourceGroupName string, automationAccountName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CertificateClient) GetResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of certificates. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client CertificateClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result CertificateListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CertificateClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client CertificateClient) ListByAutomationAccountResponder(resp *http.Response) (result CertificateListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CertificateClient) ListByAutomationAccountNextResults(lastResults CertificateListResult) (result CertificateListResult, err error) { + req, err := lastResults.CertificateListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a certificate. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. certificateName is the parameters supplied to the +// update certificate operation. parameters is the parameters supplied to the +// update certificate operation. +func (client CertificateClient) Update(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (result Certificate, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CertificateClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CertificateClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CertificateClient) UpdatePreparer(resourceGroupName string, automationAccountName string, certificateName string, parameters CertificateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "certificateName": autorest.Encode("path", certificateName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CertificateClient) UpdateResponder(resp *http.Response) (result Certificate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/client.go b/arm/automation/client.go new file mode 100644 index 000000000000..4d2bf5c16e0f --- /dev/null +++ b/arm/automation/client.go @@ -0,0 +1,52 @@ +// Package automation implements the Azure ARM Automation service API version . +// +// Composite Swagger json for Azure Automation Client +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Automation + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Automation. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/arm/automation/connection.go b/arm/automation/connection.go new file mode 100644 index 000000000000..7d3300e5d0c6 --- /dev/null +++ b/arm/automation/connection.go @@ -0,0 +1,442 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ConnectionClient is the composite Swagger json for Azure Automation Client +type ConnectionClient struct { + ManagementClient +} + +// NewConnectionClient creates an instance of the ConnectionClient client. +func NewConnectionClient(subscriptionID string) ConnectionClient { + return NewConnectionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConnectionClientWithBaseURI creates an instance of the ConnectionClient +// client. +func NewConnectionClientWithBaseURI(baseURI string, subscriptionID string) ConnectionClient { + return ConnectionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a connection. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the parameters supplied to the +// create or update connection operation. parameters is the parameters supplied +// to the create or update connection operation. +func (client ConnectionClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionCreateOrUpdateProperties.ConnectionType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionClient) CreateOrUpdateResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the connection. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the name of connection. +func (client ConnectionClient) Delete(resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionClient) DeletePreparer(resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionClient) DeleteResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the connection identified by connection name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the name of connection. +func (client ConnectionClient) Get(resourceGroupName string, automationAccountName string, connectionName string) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, connectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionClient) GetPreparer(resourceGroupName string, automationAccountName string, connectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionClient) GetResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connections. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ConnectionClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ConnectionListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ConnectionClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionClient) ListByAutomationAccountNextResults(lastResults ConnectionListResult) (result ConnectionListResult, err error) { + req, err := lastResults.ConnectionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a connection. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionName is the parameters supplied to the +// update a connection operation. parameters is the parameters supplied to the +// update a connection operation. +func (client ConnectionClient) Update(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (result Connection, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, connectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConnectionClient) UpdatePreparer(resourceGroupName string, automationAccountName string, connectionName string, parameters ConnectionUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionName": autorest.Encode("path", connectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ConnectionClient) UpdateResponder(resp *http.Response) (result Connection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/connectiontype.go b/arm/automation/connectiontype.go new file mode 100644 index 000000000000..5e2effaf2e4e --- /dev/null +++ b/arm/automation/connectiontype.go @@ -0,0 +1,366 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ConnectionTypeClient is the composite Swagger json for Azure Automation +// Client +type ConnectionTypeClient struct { + ManagementClient +} + +// NewConnectionTypeClient creates an instance of the ConnectionTypeClient +// client. +func NewConnectionTypeClient(subscriptionID string) ConnectionTypeClient { + return NewConnectionTypeClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConnectionTypeClientWithBaseURI creates an instance of the +// ConnectionTypeClient client. +func NewConnectionTypeClientWithBaseURI(baseURI string, subscriptionID string) ConnectionTypeClient { + return ConnectionTypeClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a connectiontype. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionTypeName is the parameters supplied to +// the create or update connectiontype operation. parameters is the parameters +// supplied to the create or update connectiontype operation. +func (client ConnectionTypeClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConnectionTypeCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConnectionTypeCreateOrUpdateProperties.FieldDefinitions", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, connectionTypeName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectionTypeClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, connectionTypeName string, parameters ConnectionTypeCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the connectiontype. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionTypeName is the name of connectiontype. +func (client ConnectionTypeClient) Delete(resourceGroupName string, automationAccountName string, connectionTypeName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectionTypeClient) DeletePreparer(resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the connectiontype identified by connectiontype name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. connectionTypeName is the name of connectiontype. +func (client ConnectionTypeClient) Get(resourceGroupName string, automationAccountName string, connectionTypeName string) (result ConnectionType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, connectionTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectionTypeClient) GetPreparer(resourceGroupName string, automationAccountName string, connectionTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "connectionTypeName": autorest.Encode("path", connectionTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) GetResponder(resp *http.Response) (result ConnectionType, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of connectiontypes. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ConnectionTypeClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ConnectionTypeListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ConnectionTypeClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectionTypeClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ConnectionTypeClient) ListByAutomationAccountResponder(resp *http.Response) (result ConnectionTypeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ConnectionTypeClient) ListByAutomationAccountNextResults(lastResults ConnectionTypeListResult) (result ConnectionTypeListResult, err error) { + req, err := lastResults.ConnectionTypeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ConnectionTypeClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/credential.go b/arm/automation/credential.go new file mode 100644 index 000000000000..5834f6ac000a --- /dev/null +++ b/arm/automation/credential.go @@ -0,0 +1,443 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CredentialClient is the composite Swagger json for Azure Automation Client +type CredentialClient struct { + ManagementClient +} + +// NewCredentialClient creates an instance of the CredentialClient client. +func NewCredentialClient(subscriptionID string) CredentialClient { + return NewCredentialClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCredentialClientWithBaseURI creates an instance of the CredentialClient +// client. +func NewCredentialClientWithBaseURI(baseURI string, subscriptionID string) CredentialClient { + return CredentialClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a credential. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the parameters supplied to the +// create or update credential operation. parameters is the parameters supplied +// to the create or update credential operation. +func (client CredentialClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CredentialCreateOrUpdateProperties.UserName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.CredentialCreateOrUpdateProperties.Password", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CredentialClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CredentialClient) CreateOrUpdateResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the credential. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the name of credential. +func (client CredentialClient) Delete(resourceGroupName string, automationAccountName string, credentialName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CredentialClient) DeletePreparer(resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CredentialClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the credential identified by credential name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the name of credential. +func (client CredentialClient) Get(resourceGroupName string, automationAccountName string, credentialName string) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CredentialClient) GetPreparer(resourceGroupName string, automationAccountName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CredentialClient) GetResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of credentials. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client CredentialClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result CredentialListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client CredentialClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client CredentialClient) ListByAutomationAccountResponder(resp *http.Response) (result CredentialListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client CredentialClient) ListByAutomationAccountNextResults(lastResults CredentialListResult) (result CredentialListResult, err error) { + req, err := lastResults.CredentialListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a credential. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. credentialName is the parameters supplied to the +// Update credential operation. parameters is the parameters supplied to the +// Update credential operation. +func (client CredentialClient) Update(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (result Credential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.CredentialClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.CredentialClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CredentialClient) UpdatePreparer(resourceGroupName string, automationAccountName string, credentialName string, parameters CredentialUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "credentialName": autorest.Encode("path", credentialName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CredentialClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CredentialClient) UpdateResponder(resp *http.Response) (result Credential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/dsccompilationjob.go b/arm/automation/dsccompilationjob.go new file mode 100644 index 000000000000..15fe2346d7a7 --- /dev/null +++ b/arm/automation/dsccompilationjob.go @@ -0,0 +1,373 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/uuid" + "net/http" +) + +// DscCompilationJobClient is the composite Swagger json for Azure Automation +// Client +type DscCompilationJobClient struct { + ManagementClient +} + +// NewDscCompilationJobClient creates an instance of the +// DscCompilationJobClient client. +func NewDscCompilationJobClient(subscriptionID string) DscCompilationJobClient { + return NewDscCompilationJobClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscCompilationJobClientWithBaseURI creates an instance of the +// DscCompilationJobClient client. +func NewDscCompilationJobClientWithBaseURI(baseURI string, subscriptionID string) DscCompilationJobClient { + return DscCompilationJobClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates the Dsc compilation job of the configuration. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. compilationJobID is the the DSC configuration Id. +// parameters is the parameters supplied to the create compilation job +// operation. +func (client DscCompilationJobClient) Create(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID, parameters DscCompilationJobCreateParameters) (result DscCompilationJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscCompilationJobCreateProperties.Configuration", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, compilationJobID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DscCompilationJobClient) CreatePreparer(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID, parameters DscCompilationJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobId": autorest.Encode("path", compilationJobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) CreateResponder(resp *http.Response) (result DscCompilationJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the Dsc configuration compilation job identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. compilationJobID is the Dsc configuration +// compilation job id. +func (client DscCompilationJobClient) Get(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID) (result DscCompilationJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, compilationJobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscCompilationJobClient) GetPreparer(resourceGroupName string, automationAccountName string, compilationJobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "compilationJobId": autorest.Encode("path", compilationJobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetResponder(resp *http.Response) (result DscCompilationJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetStream retrieve the job stream identified by job stream id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. jobStreamID is the job stream +// id. +func (client DscCompilationJobClient) GetStream(resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "GetStream") + } + + req, err := client.GetStreamPreparer(resourceGroupName, automationAccountName, jobID, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", nil, "Failure preparing request") + return + } + + resp, err := client.GetStreamSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure sending request") + return + } + + result, err = client.GetStreamResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "GetStream", resp, "Failure responding to request") + } + + return +} + +// GetStreamPreparer prepares the GetStream request. +func (client DscCompilationJobClient) GetStreamPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetStreamSender sends the GetStream request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) GetStreamSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetStreamResponder handles the response to the GetStream request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) GetStreamResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc compilation jobs. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client DscCompilationJobClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result DscCompilationJobListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscCompilationJobClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscCompilationJobClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscCompilationJobClient) ListByAutomationAccountResponder(resp *http.Response) (result DscCompilationJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscCompilationJobClient) ListByAutomationAccountNextResults(lastResults DscCompilationJobListResult) (result DscCompilationJobListResult, err error) { + req, err := lastResults.DscCompilationJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscCompilationJobClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/dscconfiguration.go b/arm/automation/dscconfiguration.go new file mode 100644 index 000000000000..88a8fd84562b --- /dev/null +++ b/arm/automation/dscconfiguration.go @@ -0,0 +1,444 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DscConfigurationClient is the composite Swagger json for Azure Automation +// Client +type DscConfigurationClient struct { + ManagementClient +} + +// NewDscConfigurationClient creates an instance of the DscConfigurationClient +// client. +func NewDscConfigurationClient(subscriptionID string) DscConfigurationClient { + return NewDscConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscConfigurationClientWithBaseURI creates an instance of the +// DscConfigurationClient client. +func NewDscConfigurationClientWithBaseURI(baseURI string, subscriptionID string) DscConfigurationClient { + return DscConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the configuration identified by configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the create or update +// parameters for configuration. parameters is the create or update parameters +// for configuration. +func (client DscConfigurationClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscConfigurationClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the dsc configuration identified by configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the configuration name. +func (client DscConfigurationClient) Delete(resourceGroupName string, automationAccountName string, configurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscConfigurationClient) DeletePreparer(resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the configuration identified by configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the configuration name. +func (client DscConfigurationClient) Get(resourceGroupName string, automationAccountName string, configurationName string) (result DscConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscConfigurationClient) GetPreparer(resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetResponder(resp *http.Response) (result DscConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the configuration script identified by configuration +// name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. configurationName is the configuration name. +func (client DscConfigurationClient) GetContent(resourceGroupName string, automationAccountName string, configurationName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client DscConfigurationClient) GetContentPreparer(resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of configurations. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client DscConfigurationClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result DscConfigurationListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscConfigurationClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscConfigurationClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscConfigurationClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscConfigurationClient) ListByAutomationAccountNextResults(lastResults DscConfigurationListResult) (result DscConfigurationListResult, err error) { + req, err := lastResults.DscConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/dscnode.go b/arm/automation/dscnode.go new file mode 100644 index 000000000000..fbeb848b19ae --- /dev/null +++ b/arm/automation/dscnode.go @@ -0,0 +1,362 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DscNodeClient is the composite Swagger json for Azure Automation Client +type DscNodeClient struct { + ManagementClient +} + +// NewDscNodeClient creates an instance of the DscNodeClient client. +func NewDscNodeClient(subscriptionID string) DscNodeClient { + return NewDscNodeClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscNodeClientWithBaseURI creates an instance of the DscNodeClient client. +func NewDscNodeClientWithBaseURI(baseURI string, subscriptionID string) DscNodeClient { + return DscNodeClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete the dsc node identified by node id. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. nodeID is the node id. +func (client DscNodeClient) Delete(resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeClient) DeletePreparer(resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeClient) DeleteResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the dsc node identified by node id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the node id. +func (client DscNodeClient) Get(resourceGroupName string, automationAccountName string, nodeID string) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, nodeID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeClient) GetPreparer(resourceGroupName string, automationAccountName string, nodeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeClient) GetResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc nodes. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client DscNodeClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result DscNodeListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscNodeClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeClient) ListByAutomationAccountNextResults(lastResults DscNodeListResult) (result DscNodeListResult, err error) { + req, err := lastResults.DscNodeListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the dsc node. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is parameters supplied to the update dsc +// node. parameters is parameters supplied to the update dsc node. +func (client DscNodeClient) Update(resourceGroupName string, automationAccountName string, nodeID string, parameters DscNodeUpdateParameters) (result DscNode, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, nodeID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DscNodeClient) UpdatePreparer(resourceGroupName string, automationAccountName string, nodeID string, parameters DscNodeUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DscNodeClient) UpdateResponder(resp *http.Response) (result DscNode, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/dscnodeconfiguration.go b/arm/automation/dscnodeconfiguration.go new file mode 100644 index 000000000000..32c31ea073ff --- /dev/null +++ b/arm/automation/dscnodeconfiguration.go @@ -0,0 +1,377 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DscNodeConfigurationClient is the composite Swagger json for Azure +// Automation Client +type DscNodeConfigurationClient struct { + ManagementClient +} + +// NewDscNodeConfigurationClient creates an instance of the +// DscNodeConfigurationClient client. +func NewDscNodeConfigurationClient(subscriptionID string) DscNodeConfigurationClient { + return NewDscNodeConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDscNodeConfigurationClientWithBaseURI creates an instance of the +// DscNodeConfigurationClient client. +func NewDscNodeConfigurationClientWithBaseURI(baseURI string, subscriptionID string) DscNodeConfigurationClient { + return DscNodeConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the node configuration identified by node +// configuration name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeConfigurationName is the create or update +// parameters for configuration. parameters is the create or update parameters +// for configuration. +func (client DscNodeConfigurationClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (result DscNodeConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Source.Hash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Configuration", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, nodeConfigurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DscNodeConfigurationClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, nodeConfigurationName string, parameters DscNodeConfigurationCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscNodeConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the Dsc node configurations by node configuration. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeConfigurationName is the Dsc node configuration +// name. +func (client DscNodeConfigurationClient) Delete(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DscNodeConfigurationClient) DeletePreparer(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the Dsc node configurations by node configuration. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeConfigurationName is the Dsc node configuration +// name. +func (client DscNodeConfigurationClient) Get(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (result DscNodeConfiguration, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, nodeConfigurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DscNodeConfigurationClient) GetPreparer(resourceGroupName string, automationAccountName string, nodeConfigurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeConfigurationName": autorest.Encode("path", nodeConfigurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) GetResponder(resp *http.Response) (result DscNodeConfiguration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of dsc node configurations. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client DscNodeConfigurationClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result DscNodeConfigurationListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client DscNodeConfigurationClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client DscNodeConfigurationClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client DscNodeConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscNodeConfigurationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client DscNodeConfigurationClient) ListByAutomationAccountNextResults(lastResults DscNodeConfigurationListResult) (result DscNodeConfigurationListResult, err error) { + req, err := lastResults.DscNodeConfigurationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.DscNodeConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/fields.go b/arm/automation/fields.go new file mode 100644 index 000000000000..ef597c0fb63c --- /dev/null +++ b/arm/automation/fields.go @@ -0,0 +1,117 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FieldsClient is the composite Swagger json for Azure Automation Client +type FieldsClient struct { + ManagementClient +} + +// NewFieldsClient creates an instance of the FieldsClient client. +func NewFieldsClient(subscriptionID string) FieldsClient { + return NewFieldsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFieldsClientWithBaseURI creates an instance of the FieldsClient client. +func NewFieldsClientWithBaseURI(baseURI string, subscriptionID string) FieldsClient { + return FieldsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByType retrieve a list of fields of a given type identified by module +// name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. typeName is the +// name of type. +func (client FieldsClient) ListByType(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.FieldsClient", "ListByType") + } + + req, err := client.ListByTypePreparer(resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure sending request") + return + } + + result, err = client.ListByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.FieldsClient", "ListByType", resp, "Failure responding to request") + } + + return +} + +// ListByTypePreparer prepares the ListByType request. +func (client FieldsClient) ListByTypePreparer(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByTypeSender sends the ListByType request. The method will close the +// http.Response Body if it receives an error. +func (client FieldsClient) ListByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByTypeResponder handles the response to the ListByType request. The method always +// closes the http.Response Body. +func (client FieldsClient) ListByTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/hybridrunbookworkergroup.go b/arm/automation/hybridrunbookworkergroup.go new file mode 100644 index 000000000000..b36eb3b681e8 --- /dev/null +++ b/arm/automation/hybridrunbookworkergroup.go @@ -0,0 +1,363 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// HybridRunbookWorkerGroupClient is the composite Swagger json for Azure +// Automation Client +type HybridRunbookWorkerGroupClient struct { + ManagementClient +} + +// NewHybridRunbookWorkerGroupClient creates an instance of the +// HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClient(subscriptionID string) HybridRunbookWorkerGroupClient { + return NewHybridRunbookWorkerGroupClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHybridRunbookWorkerGroupClientWithBaseURI creates an instance of the +// HybridRunbookWorkerGroupClient client. +func NewHybridRunbookWorkerGroupClientWithBaseURI(baseURI string, subscriptionID string) HybridRunbookWorkerGroupClient { + return HybridRunbookWorkerGroupClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete a hybrid runbook worker group. +// +// resourceGroupName is the resource group name. automationAccountName is +// automation account name. hybridRunbookWorkerGroupName is the hybrid runbook +// worker group name +func (client HybridRunbookWorkerGroupClient) Delete(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HybridRunbookWorkerGroupClient) DeletePreparer(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve a hybrid runbook worker group. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. hybridRunbookWorkerGroupName is the hybrid runbook +// worker group name +func (client HybridRunbookWorkerGroupClient) Get(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HybridRunbookWorkerGroupClient) GetPreparer(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) GetResponder(resp *http.Response) (result HybridRunbookWorkerGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of hybrid runbook worker groups. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result HybridRunbookWorkerGroupsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountResponder(resp *http.Response) (result HybridRunbookWorkerGroupsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client HybridRunbookWorkerGroupClient) ListByAutomationAccountNextResults(lastResults HybridRunbookWorkerGroupsListResult) (result HybridRunbookWorkerGroupsListResult, err error) { + req, err := lastResults.HybridRunbookWorkerGroupsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a hybrid runbook worker group. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. hybridRunbookWorkerGroupName is the hybrid runbook +// worker group name parameters is the hybrid runbook worker group +func (client HybridRunbookWorkerGroupClient) Update(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (result HybridRunbookWorkerGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.HybridRunbookWorkerGroupClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.HybridRunbookWorkerGroupClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client HybridRunbookWorkerGroupClient) UpdatePreparer(resourceGroupName string, automationAccountName string, hybridRunbookWorkerGroupName string, parameters HybridRunbookWorkerGroupUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "hybridRunbookWorkerGroupName": autorest.Encode("path", hybridRunbookWorkerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client HybridRunbookWorkerGroupClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client HybridRunbookWorkerGroupClient) UpdateResponder(resp *http.Response) (result HybridRunbookWorkerGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/job.go b/arm/automation/job.go new file mode 100644 index 000000000000..d1257ab970cf --- /dev/null +++ b/arm/automation/job.go @@ -0,0 +1,654 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/uuid" + "net/http" +) + +// JobClient is the composite Swagger json for Azure Automation Client +type JobClient struct { + ManagementClient +} + +// NewJobClient creates an instance of the JobClient client. +func NewJobClient(subscriptionID string) JobClient { + return NewJobClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobClientWithBaseURI creates an instance of the JobClient client. +func NewJobClientWithBaseURI(baseURI string, subscriptionID string) JobClient { + return JobClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a job of the runbook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. parameters is the parameters +// supplied to the create job operation. +func (client JobClient) Create(resourceGroupName string, automationAccountName string, jobID uuid.UUID, parameters JobCreateParameters) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobCreateProperties.Runbook", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, jobID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobClient) CreatePreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID, parameters JobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobClient) CreateResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the job identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Get(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobClient) GetPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetOutput retrieve the job output identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) GetOutput(resourceGroupName string, automationAccountName string, jobID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "GetOutput") + } + + req, err := client.GetOutputPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", nil, "Failure preparing request") + return + } + + resp, err := client.GetOutputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure sending request") + return + } + + result, err = client.GetOutputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetOutput", resp, "Failure responding to request") + } + + return +} + +// GetOutputPreparer prepares the GetOutput request. +func (client JobClient) GetOutputPreparer(resourceGroupName string, automationAccountName string, jobID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/output", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetOutputSender sends the GetOutput request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetOutputSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetOutputResponder handles the response to the GetOutput request. The method always +// closes the http.Response Body. +func (client JobClient) GetOutputResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// GetRunbookContent retrieve the runbook content of the job identified by job +// id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) GetRunbookContent(resourceGroupName string, automationAccountName string, jobID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "GetRunbookContent") + } + + req, err := client.GetRunbookContentPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetRunbookContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure sending request") + return + } + + result, err = client.GetRunbookContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "GetRunbookContent", resp, "Failure responding to request") + } + + return +} + +// GetRunbookContentPreparer prepares the GetRunbookContent request. +func (client JobClient) GetRunbookContentPreparer(resourceGroupName string, automationAccountName string, jobID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/runbookContent", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetRunbookContentSender sends the GetRunbookContent request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) GetRunbookContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetRunbookContentResponder handles the response to the GetRunbookContent request. The method always +// closes the http.Response Body. +func (client JobClient) GetRunbookContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of jobs. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client JobClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result JobListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client JobClient) ListByAutomationAccountResponder(resp *http.Response) (result JobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobClient) ListByAutomationAccountNextResults(lastResults JobListResult) (result JobListResult, err error) { + req, err := lastResults.JobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Resume resume the job identified by jobId. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Resume(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Resume") + } + + req, err := client.ResumePreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client JobClient) ResumePreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client JobClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the job identified by jobId. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Stop(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Stop") + } + + req, err := client.StopPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client JobClient) StopPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client JobClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the job identified by jobId. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. +func (client JobClient) Suspend(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobClient", "Suspend") + } + + req, err := client.SuspendPreparer(resourceGroupName, automationAccountName, jobID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client JobClient) SuspendPreparer(resourceGroupName string, automationAccountName string, jobID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client JobClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client JobClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/arm/automation/jobschedule.go b/arm/automation/jobschedule.go new file mode 100644 index 000000000000..a10ec7dba6dd --- /dev/null +++ b/arm/automation/jobschedule.go @@ -0,0 +1,365 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/uuid" + "net/http" +) + +// JobScheduleClient is the composite Swagger json for Azure Automation Client +type JobScheduleClient struct { + ManagementClient +} + +// NewJobScheduleClient creates an instance of the JobScheduleClient client. +func NewJobScheduleClient(subscriptionID string) JobScheduleClient { + return NewJobScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobScheduleClientWithBaseURI creates an instance of the JobScheduleClient +// client. +func NewJobScheduleClientWithBaseURI(baseURI string, subscriptionID string) JobScheduleClient { + return JobScheduleClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a job schedule. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobScheduleID is the job schedule name. parameters +// is the parameters supplied to the create job schedule operation. +func (client JobScheduleClient) Create(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobScheduleCreateProperties.Schedule", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobScheduleCreateProperties.Runbook", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, jobScheduleID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobScheduleClient) CreatePreparer(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID, parameters JobScheduleCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) CreateResponder(resp *http.Response) (result JobSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the job schedule identified by job schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobScheduleID is the job schedule name. +func (client JobScheduleClient) Delete(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobScheduleClient) DeletePreparer(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the job schedule identified by job schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobScheduleID is the job schedule name. +func (client JobScheduleClient) Get(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (result JobSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, jobScheduleID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobScheduleClient) GetPreparer(resourceGroupName string, automationAccountName string, jobScheduleID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobScheduleId": autorest.Encode("path", jobScheduleID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) GetResponder(resp *http.Response) (result JobSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of job schedules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client JobScheduleClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result JobScheduleListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobScheduleClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client JobScheduleClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client JobScheduleClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client JobScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result JobScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client JobScheduleClient) ListByAutomationAccountNextResults(lastResults JobScheduleListResult) (result JobScheduleListResult, err error) { + req, err := lastResults.JobScheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobScheduleClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/jobstream.go b/arm/automation/jobstream.go new file mode 100644 index 000000000000..95b497598e34 --- /dev/null +++ b/arm/automation/jobstream.go @@ -0,0 +1,218 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// JobStreamClient is the composite Swagger json for Azure Automation Client +type JobStreamClient struct { + ManagementClient +} + +// NewJobStreamClient creates an instance of the JobStreamClient client. +func NewJobStreamClient(subscriptionID string) JobStreamClient { + return NewJobStreamClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobStreamClientWithBaseURI creates an instance of the JobStreamClient +// client. +func NewJobStreamClientWithBaseURI(baseURI string, subscriptionID string) JobStreamClient { + return JobStreamClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the job stream identified by job stream id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job id. jobStreamID is the job stream +// id. +func (client JobStreamClient) Get(resourceGroupName string, automationAccountName string, jobID string, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobStreamClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, jobID, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStreamClient) GetPreparer(resourceGroupName string, automationAccountName string, jobID string, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStreamClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob retrieve a list of jobs streams identified by job id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. jobID is the job Id. filter is the filter to apply +// on the operation. +func (client JobStreamClient) ListByJob(resourceGroupName string, automationAccountName string, jobID string, filter string) (result JobStreamListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.JobStreamClient", "ListByJob") + } + + req, err := client.ListByJobPreparer(resourceGroupName, automationAccountName, jobID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure sending request") + return + } + + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobStreamClient) ListByJobPreparer(resourceGroupName string, automationAccountName string, jobID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobId": autorest.Encode("path", jobID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobId}/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobStreamClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobStreamClient) ListByJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJobNextResults retrieves the next set of results, if any. +func (client JobStreamClient) ListByJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.JobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure sending next results request") + } + + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.JobStreamClient", "ListByJob", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/models.go b/arm/automation/models.go new file mode 100644 index 000000000000..9bba30646a3b --- /dev/null +++ b/arm/automation/models.go @@ -0,0 +1,1926 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/satori/uuid" + "io" + "net/http" +) + +// AccountState enumerates the values for account state. +type AccountState string + +const ( + // Ok specifies the ok state for account state. + Ok AccountState = "Ok" + // Suspended specifies the suspended state for account state. + Suspended AccountState = "Suspended" + // Unavailable specifies the unavailable state for account state. + Unavailable AccountState = "Unavailable" +) + +// AgentRegistrationKeyName enumerates the values for agent registration key +// name. +type AgentRegistrationKeyName string + +const ( + // Primary specifies the primary state for agent registration key name. + Primary AgentRegistrationKeyName = "Primary" + // Secondary specifies the secondary state for agent registration key name. + Secondary AgentRegistrationKeyName = "Secondary" +) + +// ContentSourceType enumerates the values for content source type. +type ContentSourceType string + +const ( + // EmbeddedContent specifies the embedded content state for content source + // type. + EmbeddedContent ContentSourceType = "embeddedContent" + // URI specifies the uri state for content source type. + URI ContentSourceType = "uri" +) + +// DscConfigurationProvisioningState enumerates the values for dsc +// configuration provisioning state. +type DscConfigurationProvisioningState string + +const ( + // Succeeded specifies the succeeded state for dsc configuration + // provisioning state. + Succeeded DscConfigurationProvisioningState = "Succeeded" +) + +// DscConfigurationState enumerates the values for dsc configuration state. +type DscConfigurationState string + +const ( + // DscConfigurationStateEdit specifies the dsc configuration state edit + // state for dsc configuration state. + DscConfigurationStateEdit DscConfigurationState = "Edit" + // DscConfigurationStateNew specifies the dsc configuration state new state + // for dsc configuration state. + DscConfigurationStateNew DscConfigurationState = "New" + // DscConfigurationStatePublished specifies the dsc configuration state + // published state for dsc configuration state. + DscConfigurationStatePublished DscConfigurationState = "Published" +) + +// HTTPStatusCode enumerates the values for http status code. +type HTTPStatusCode string + +const ( + // Accepted specifies the accepted state for http status code. + Accepted HTTPStatusCode = "Accepted" + // Ambiguous specifies the ambiguous state for http status code. + Ambiguous HTTPStatusCode = "Ambiguous" + // BadGateway specifies the bad gateway state for http status code. + BadGateway HTTPStatusCode = "BadGateway" + // BadRequest specifies the bad request state for http status code. + BadRequest HTTPStatusCode = "BadRequest" + // Conflict specifies the conflict state for http status code. + Conflict HTTPStatusCode = "Conflict" + // Continue specifies the continue state for http status code. + Continue HTTPStatusCode = "Continue" + // Created specifies the created state for http status code. + Created HTTPStatusCode = "Created" + // ExpectationFailed specifies the expectation failed state for http status + // code. + ExpectationFailed HTTPStatusCode = "ExpectationFailed" + // Forbidden specifies the forbidden state for http status code. + Forbidden HTTPStatusCode = "Forbidden" + // Found specifies the found state for http status code. + Found HTTPStatusCode = "Found" + // GatewayTimeout specifies the gateway timeout state for http status code. + GatewayTimeout HTTPStatusCode = "GatewayTimeout" + // Gone specifies the gone state for http status code. + Gone HTTPStatusCode = "Gone" + // HTTPVersionNotSupported specifies the http version not supported state + // for http status code. + HTTPVersionNotSupported HTTPStatusCode = "HttpVersionNotSupported" + // InternalServerError specifies the internal server error state for http + // status code. + InternalServerError HTTPStatusCode = "InternalServerError" + // LengthRequired specifies the length required state for http status code. + LengthRequired HTTPStatusCode = "LengthRequired" + // MethodNotAllowed specifies the method not allowed state for http status + // code. + MethodNotAllowed HTTPStatusCode = "MethodNotAllowed" + // Moved specifies the moved state for http status code. + Moved HTTPStatusCode = "Moved" + // MovedPermanently specifies the moved permanently state for http status + // code. + MovedPermanently HTTPStatusCode = "MovedPermanently" + // MultipleChoices specifies the multiple choices state for http status + // code. + MultipleChoices HTTPStatusCode = "MultipleChoices" + // NoContent specifies the no content state for http status code. + NoContent HTTPStatusCode = "NoContent" + // NonAuthoritativeInformation specifies the non authoritative information + // state for http status code. + NonAuthoritativeInformation HTTPStatusCode = "NonAuthoritativeInformation" + // NotAcceptable specifies the not acceptable state for http status code. + NotAcceptable HTTPStatusCode = "NotAcceptable" + // NotFound specifies the not found state for http status code. + NotFound HTTPStatusCode = "NotFound" + // NotImplemented specifies the not implemented state for http status code. + NotImplemented HTTPStatusCode = "NotImplemented" + // NotModified specifies the not modified state for http status code. + NotModified HTTPStatusCode = "NotModified" + // OK specifies the ok state for http status code. + OK HTTPStatusCode = "OK" + // PartialContent specifies the partial content state for http status code. + PartialContent HTTPStatusCode = "PartialContent" + // PaymentRequired specifies the payment required state for http status + // code. + PaymentRequired HTTPStatusCode = "PaymentRequired" + // PreconditionFailed specifies the precondition failed state for http + // status code. + PreconditionFailed HTTPStatusCode = "PreconditionFailed" + // ProxyAuthenticationRequired specifies the proxy authentication required + // state for http status code. + ProxyAuthenticationRequired HTTPStatusCode = "ProxyAuthenticationRequired" + // Redirect specifies the redirect state for http status code. + Redirect HTTPStatusCode = "Redirect" + // RedirectKeepVerb specifies the redirect keep verb state for http status + // code. + RedirectKeepVerb HTTPStatusCode = "RedirectKeepVerb" + // RedirectMethod specifies the redirect method state for http status code. + RedirectMethod HTTPStatusCode = "RedirectMethod" + // RequestedRangeNotSatisfiable specifies the requested range not + // satisfiable state for http status code. + RequestedRangeNotSatisfiable HTTPStatusCode = "RequestedRangeNotSatisfiable" + // RequestEntityTooLarge specifies the request entity too large state for + // http status code. + RequestEntityTooLarge HTTPStatusCode = "RequestEntityTooLarge" + // RequestTimeout specifies the request timeout state for http status code. + RequestTimeout HTTPStatusCode = "RequestTimeout" + // RequestURITooLong specifies the request uri too long state for http + // status code. + RequestURITooLong HTTPStatusCode = "RequestUriTooLong" + // ResetContent specifies the reset content state for http status code. + ResetContent HTTPStatusCode = "ResetContent" + // SeeOther specifies the see other state for http status code. + SeeOther HTTPStatusCode = "SeeOther" + // ServiceUnavailable specifies the service unavailable state for http + // status code. + ServiceUnavailable HTTPStatusCode = "ServiceUnavailable" + // SwitchingProtocols specifies the switching protocols state for http + // status code. + SwitchingProtocols HTTPStatusCode = "SwitchingProtocols" + // TemporaryRedirect specifies the temporary redirect state for http status + // code. + TemporaryRedirect HTTPStatusCode = "TemporaryRedirect" + // Unauthorized specifies the unauthorized state for http status code. + Unauthorized HTTPStatusCode = "Unauthorized" + // UnsupportedMediaType specifies the unsupported media type state for http + // status code. + UnsupportedMediaType HTTPStatusCode = "UnsupportedMediaType" + // Unused specifies the unused state for http status code. + Unused HTTPStatusCode = "Unused" + // UpgradeRequired specifies the upgrade required state for http status + // code. + UpgradeRequired HTTPStatusCode = "UpgradeRequired" + // UseProxy specifies the use proxy state for http status code. + UseProxy HTTPStatusCode = "UseProxy" +) + +// JobStatus enumerates the values for job status. +type JobStatus string + +const ( + // JobStatusActivating specifies the job status activating state for job + // status. + JobStatusActivating JobStatus = "Activating" + // JobStatusBlocked specifies the job status blocked state for job status. + JobStatusBlocked JobStatus = "Blocked" + // JobStatusCompleted specifies the job status completed state for job + // status. + JobStatusCompleted JobStatus = "Completed" + // JobStatusDisconnected specifies the job status disconnected state for + // job status. + JobStatusDisconnected JobStatus = "Disconnected" + // JobStatusFailed specifies the job status failed state for job status. + JobStatusFailed JobStatus = "Failed" + // JobStatusNew specifies the job status new state for job status. + JobStatusNew JobStatus = "New" + // JobStatusRemoving specifies the job status removing state for job + // status. + JobStatusRemoving JobStatus = "Removing" + // JobStatusResuming specifies the job status resuming state for job + // status. + JobStatusResuming JobStatus = "Resuming" + // JobStatusRunning specifies the job status running state for job status. + JobStatusRunning JobStatus = "Running" + // JobStatusStopped specifies the job status stopped state for job status. + JobStatusStopped JobStatus = "Stopped" + // JobStatusStopping specifies the job status stopping state for job + // status. + JobStatusStopping JobStatus = "Stopping" + // JobStatusSuspended specifies the job status suspended state for job + // status. + JobStatusSuspended JobStatus = "Suspended" + // JobStatusSuspending specifies the job status suspending state for job + // status. + JobStatusSuspending JobStatus = "Suspending" +) + +// JobStreamType enumerates the values for job stream type. +type JobStreamType string + +const ( + // Any specifies the any state for job stream type. + Any JobStreamType = "Any" + // Debug specifies the debug state for job stream type. + Debug JobStreamType = "Debug" + // Error specifies the error state for job stream type. + Error JobStreamType = "Error" + // Output specifies the output state for job stream type. + Output JobStreamType = "Output" + // Progress specifies the progress state for job stream type. + Progress JobStreamType = "Progress" + // Verbose specifies the verbose state for job stream type. + Verbose JobStreamType = "Verbose" + // Warning specifies the warning state for job stream type. + Warning JobStreamType = "Warning" +) + +// ModuleProvisioningState enumerates the values for module provisioning state. +type ModuleProvisioningState string + +const ( + // ModuleProvisioningStateActivitiesStored specifies the module + // provisioning state activities stored state for module provisioning + // state. + ModuleProvisioningStateActivitiesStored ModuleProvisioningState = "ActivitiesStored" + // ModuleProvisioningStateCancelled specifies the module provisioning state + // cancelled state for module provisioning state. + ModuleProvisioningStateCancelled ModuleProvisioningState = "Cancelled" + // ModuleProvisioningStateConnectionTypeImported specifies the module + // provisioning state connection type imported state for module + // provisioning state. + ModuleProvisioningStateConnectionTypeImported ModuleProvisioningState = "ConnectionTypeImported" + // ModuleProvisioningStateContentDownloaded specifies the module + // provisioning state content downloaded state for module provisioning + // state. + ModuleProvisioningStateContentDownloaded ModuleProvisioningState = "ContentDownloaded" + // ModuleProvisioningStateContentRetrieved specifies the module + // provisioning state content retrieved state for module provisioning + // state. + ModuleProvisioningStateContentRetrieved ModuleProvisioningState = "ContentRetrieved" + // ModuleProvisioningStateContentStored specifies the module provisioning + // state content stored state for module provisioning state. + ModuleProvisioningStateContentStored ModuleProvisioningState = "ContentStored" + // ModuleProvisioningStateContentValidated specifies the module + // provisioning state content validated state for module provisioning + // state. + ModuleProvisioningStateContentValidated ModuleProvisioningState = "ContentValidated" + // ModuleProvisioningStateCreated specifies the module provisioning state + // created state for module provisioning state. + ModuleProvisioningStateCreated ModuleProvisioningState = "Created" + // ModuleProvisioningStateCreating specifies the module provisioning state + // creating state for module provisioning state. + ModuleProvisioningStateCreating ModuleProvisioningState = "Creating" + // ModuleProvisioningStateFailed specifies the module provisioning state + // failed state for module provisioning state. + ModuleProvisioningStateFailed ModuleProvisioningState = "Failed" + // ModuleProvisioningStateModuleDataStored specifies the module + // provisioning state module data stored state for module provisioning + // state. + ModuleProvisioningStateModuleDataStored ModuleProvisioningState = "ModuleDataStored" + // ModuleProvisioningStateModuleImportRunbookComplete specifies the module + // provisioning state module import runbook complete state for module + // provisioning state. + ModuleProvisioningStateModuleImportRunbookComplete ModuleProvisioningState = "ModuleImportRunbookComplete" + // ModuleProvisioningStateRunningImportModuleRunbook specifies the module + // provisioning state running import module runbook state for module + // provisioning state. + ModuleProvisioningStateRunningImportModuleRunbook ModuleProvisioningState = "RunningImportModuleRunbook" + // ModuleProvisioningStateStartingImportModuleRunbook specifies the module + // provisioning state starting import module runbook state for module + // provisioning state. + ModuleProvisioningStateStartingImportModuleRunbook ModuleProvisioningState = "StartingImportModuleRunbook" + // ModuleProvisioningStateSucceeded specifies the module provisioning state + // succeeded state for module provisioning state. + ModuleProvisioningStateSucceeded ModuleProvisioningState = "Succeeded" + // ModuleProvisioningStateUpdating specifies the module provisioning state + // updating state for module provisioning state. + ModuleProvisioningStateUpdating ModuleProvisioningState = "Updating" +) + +// RunbookProvisioningState enumerates the values for runbook provisioning +// state. +type RunbookProvisioningState string + +const ( + // RunbookProvisioningStateSucceeded specifies the runbook provisioning + // state succeeded state for runbook provisioning state. + RunbookProvisioningStateSucceeded RunbookProvisioningState = "Succeeded" +) + +// RunbookState enumerates the values for runbook state. +type RunbookState string + +const ( + // RunbookStateEdit specifies the runbook state edit state for runbook + // state. + RunbookStateEdit RunbookState = "Edit" + // RunbookStateNew specifies the runbook state new state for runbook state. + RunbookStateNew RunbookState = "New" + // RunbookStatePublished specifies the runbook state published state for + // runbook state. + RunbookStatePublished RunbookState = "Published" +) + +// RunbookTypeEnum enumerates the values for runbook type enum. +type RunbookTypeEnum string + +const ( + // Graph specifies the graph state for runbook type enum. + Graph RunbookTypeEnum = "Graph" + // GraphPowerShell specifies the graph power shell state for runbook type + // enum. + GraphPowerShell RunbookTypeEnum = "GraphPowerShell" + // GraphPowerShellWorkflow specifies the graph power shell workflow state + // for runbook type enum. + GraphPowerShellWorkflow RunbookTypeEnum = "GraphPowerShellWorkflow" + // PowerShell specifies the power shell state for runbook type enum. + PowerShell RunbookTypeEnum = "PowerShell" + // PowerShellWorkflow specifies the power shell workflow state for runbook + // type enum. + PowerShellWorkflow RunbookTypeEnum = "PowerShellWorkflow" + // Script specifies the script state for runbook type enum. + Script RunbookTypeEnum = "Script" +) + +// ScheduleDay enumerates the values for schedule day. +type ScheduleDay string + +const ( + // Friday specifies the friday state for schedule day. + Friday ScheduleDay = "Friday" + // Monday specifies the monday state for schedule day. + Monday ScheduleDay = "Monday" + // Saturday specifies the saturday state for schedule day. + Saturday ScheduleDay = "Saturday" + // Sunday specifies the sunday state for schedule day. + Sunday ScheduleDay = "Sunday" + // Thursday specifies the thursday state for schedule day. + Thursday ScheduleDay = "Thursday" + // Tuesday specifies the tuesday state for schedule day. + Tuesday ScheduleDay = "Tuesday" + // Wednesday specifies the wednesday state for schedule day. + Wednesday ScheduleDay = "Wednesday" +) + +// ScheduleFrequency enumerates the values for schedule frequency. +type ScheduleFrequency string + +const ( + // Day specifies the day state for schedule frequency. + Day ScheduleFrequency = "Day" + // Hour specifies the hour state for schedule frequency. + Hour ScheduleFrequency = "Hour" + // Month specifies the month state for schedule frequency. + Month ScheduleFrequency = "Month" + // OneTime specifies the one time state for schedule frequency. + OneTime ScheduleFrequency = "OneTime" + // Week specifies the week state for schedule frequency. + Week ScheduleFrequency = "Week" +) + +// SkuNameEnum enumerates the values for sku name enum. +type SkuNameEnum string + +const ( + // Basic specifies the basic state for sku name enum. + Basic SkuNameEnum = "Basic" + // Free specifies the free state for sku name enum. + Free SkuNameEnum = "Free" +) + +// Account is definition of the automation account type. +type Account struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *AccountProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// AccountCreateOrUpdateParameters is the parameters supplied to the create or +// update automation account operation. +type AccountCreateOrUpdateParameters struct { + *AccountCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// AccountCreateOrUpdateProperties is the parameters supplied to the create or +// update account properties. +type AccountCreateOrUpdateProperties struct { + Sku *Sku `json:"sku,omitempty"` +} + +// AccountListResult is the response model for the list account operation. +type AccountListResult struct { + autorest.Response `json:"-"` + Value *[]Account `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// AccountListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client AccountListResult) AccountListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// AccountProperties is definition of the account property. +type AccountProperties struct { + Sku *Sku `json:"sku,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + State AccountState `json:"state,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// AccountUpdateParameters is the parameters supplied to the update automation +// account operation. +type AccountUpdateParameters struct { + *AccountUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// AccountUpdateProperties is the parameters supplied to the update account +// properties. +type AccountUpdateProperties struct { + Sku *Sku `json:"sku,omitempty"` +} + +// Activity is definition of the activity. +type Activity struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ActivityProperties `json:"properties,omitempty"` +} + +// ActivityListResult is the response model for the list activity operation. +type ActivityListResult struct { + autorest.Response `json:"-"` + Value *[]Activity `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ActivityListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ActivityListResult) ActivityListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ActivityOutputType is definition of the activity output type. +type ActivityOutputType struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// ActivityParameter is definition of the activity parameter. +type ActivityParameter struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + IsMandatory *bool `json:"isMandatory,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Position *bool `json:"position,omitempty"` + ValueFromPipeline *bool `json:"valueFromPipeline,omitempty"` + ValueFromPipelineByPropertyName *bool `json:"valueFromPipelineByPropertyName,omitempty"` + ValueFromRemainingArguments *bool `json:"valueFromRemainingArguments,omitempty"` +} + +// ActivityParameterSet is definition of the activity parameter set. +type ActivityParameterSet struct { + Name *string `json:"name,omitempty"` + Parameters *[]ActivityParameter `json:"parameters,omitempty"` +} + +// ActivityProperties is properties of the activity. +type ActivityProperties struct { + Definition *string `json:"definition,omitempty"` + ParameterSets *[]ActivityParameterSet `json:"parameterSets,omitempty"` + OutputTypes *[]ActivityOutputType `json:"outputTypes,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// AdvancedSchedule is the properties of the create Advanced Schedule. +type AdvancedSchedule struct { + WeekDays *[]string `json:"weekDays,omitempty"` + MonthDays *[]int32 `json:"monthDays,omitempty"` + MonthlyOccurrences *[]AdvancedScheduleMonthlyOccurrence `json:"monthlyOccurrences,omitempty"` +} + +// AdvancedScheduleMonthlyOccurrence is the properties of the create advanced +// schedule monthly occurrence. +type AdvancedScheduleMonthlyOccurrence struct { + Occurrence *int32 `json:"occurrence,omitempty"` + Day ScheduleDay `json:"day,omitempty"` +} + +// AgentRegistration is definition of the agent registration infomration type. +type AgentRegistration struct { + autorest.Response `json:"-"` + DscMetaConfiguration *string `json:"dscMetaConfiguration,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + Keys *AgentRegistrationKeys `json:"keys,omitempty"` + ID *string `json:"id,omitempty"` +} + +// AgentRegistrationKeys is definition of the agent registration keys. +type AgentRegistrationKeys struct { + Primary *string `json:"primary,omitempty"` + Secondary *string `json:"secondary,omitempty"` +} + +// AgentRegistrationRegenerateKeyParameter is the parameters supplied to the +// regenerate keys operation. +type AgentRegistrationRegenerateKeyParameter struct { + KeyName AgentRegistrationKeyName `json:"keyName,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// Certificate is definition of the certificate. +type Certificate struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *CertificateProperties `json:"properties,omitempty"` +} + +// CertificateCreateOrUpdateParameters is the parameters supplied to the create +// or update or replace certificate operation. +type CertificateCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CertificateCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// CertificateCreateOrUpdateProperties is the properties of the create +// certificate operation. +type CertificateCreateOrUpdateProperties struct { + Base64Value *string `json:"base64Value,omitempty"` + Description *string `json:"description,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + IsExportable *bool `json:"isExportable,omitempty"` +} + +// CertificateListResult is the response model for the list certificate +// operation. +type CertificateListResult struct { + autorest.Response `json:"-"` + Value *[]Certificate `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// CertificateListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client CertificateListResult) CertificateListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// CertificateProperties is properties of the certificate. +type CertificateProperties struct { + Thumbprint *string `json:"thumbprint,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + IsExportable *bool `json:"isExportable,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// CertificateUpdateParameters is the parameters supplied to the update +// certificate operation. +type CertificateUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CertificateUpdateProperties `json:"properties,omitempty"` +} + +// CertificateUpdateProperties is the properties of the update certificate +// operation +type CertificateUpdateProperties struct { + Description *string `json:"description,omitempty"` +} + +// Connection is definition of the connection. +type Connection struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ConnectionProperties `json:"properties,omitempty"` +} + +// ConnectionCreateOrUpdateParameters is the parameters supplied to the create +// or update connection operation. +type ConnectionCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ConnectionCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// ConnectionCreateOrUpdateProperties is the properties of the create +// connection properties +type ConnectionCreateOrUpdateProperties struct { + Description *string `json:"description,omitempty"` + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + FieldDefinitionValues *map[string]*string `json:"fieldDefinitionValues,omitempty"` +} + +// ConnectionListResult is the response model for the list connection +// operation. +type ConnectionListResult struct { + autorest.Response `json:"-"` + Value *[]Connection `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ConnectionListResult) ConnectionListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ConnectionProperties is definition of the connection properties. +type ConnectionProperties struct { + ConnectionType *ConnectionTypeAssociationProperty `json:"connectionType,omitempty"` + FieldDefinitionValues *map[string]*string `json:"fieldDefinitionValues,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ConnectionType is definition of the connection type. +type ConnectionType struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ConnectionTypeProperties `json:"properties,omitempty"` +} + +// ConnectionTypeAssociationProperty is the connection type property associated +// with the entity. +type ConnectionTypeAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// ConnectionTypeCreateOrUpdateParameters is the parameters supplied to the +// create or update connection type operation. +type ConnectionTypeCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ConnectionTypeCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// ConnectionTypeCreateOrUpdateProperties is the properties of the create +// connection type. +type ConnectionTypeCreateOrUpdateProperties struct { + IsGlobal *bool `json:"isGlobal,omitempty"` + FieldDefinitions *map[string]*FieldDefinition `json:"fieldDefinitions,omitempty"` +} + +// ConnectionTypeListResult is the response model for the list connection type +// operation. +type ConnectionTypeListResult struct { + autorest.Response `json:"-"` + Value *[]ConnectionType `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectionTypeListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ConnectionTypeListResult) ConnectionTypeListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ConnectionTypeProperties is properties of the connection type. +type ConnectionTypeProperties struct { + IsGlobal *bool `json:"isGlobal,omitempty"` + FieldDefinitions *map[string]*FieldDefinition `json:"fieldDefinitions,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ConnectionUpdateParameters is the parameters supplied to the update +// connection operation. +type ConnectionUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ConnectionUpdateProperties `json:"properties,omitempty"` +} + +// ConnectionUpdateProperties is the properties of the update connection +// operation. +type ConnectionUpdateProperties struct { + Description *string `json:"description,omitempty"` + FieldDefinitionValues *map[string]*string `json:"fieldDefinitionValues,omitempty"` +} + +// ContentHash is definition of the runbook property type. +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ContentLink is definition of the content link. +type ContentLink struct { + URI *string `json:"uri,omitempty"` + ContentHash *ContentHash `json:"contentHash,omitempty"` + Version *string `json:"version,omitempty"` +} + +// ContentSource is definition of the content source. +type ContentSource struct { + Hash *ContentHash `json:"hash,omitempty"` + Type ContentSourceType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` + Version *string `json:"version,omitempty"` +} + +// Credential is definition of the credential. +type Credential struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *CredentialProperties `json:"properties,omitempty"` +} + +// CredentialCreateOrUpdateParameters is the parameters supplied to the create +// or update credential operation. +type CredentialCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CredentialCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// CredentialCreateOrUpdateProperties is the properties of the create +// cerdential operation. +type CredentialCreateOrUpdateProperties struct { + UserName *string `json:"userName,omitempty"` + Password *string `json:"password,omitempty"` + Description *string `json:"description,omitempty"` +} + +// CredentialListResult is the response model for the list credential +// operation. +type CredentialListResult struct { + autorest.Response `json:"-"` + Value *[]Credential `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// CredentialListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client CredentialListResult) CredentialListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// CredentialProperties is definition of the credential properties +type CredentialProperties struct { + UserName *string `json:"userName,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// CredentialUpdateParameters is the parameters supplied to the Update +// credential operation. +type CredentialUpdateParameters struct { + Name *string `json:"name,omitempty"` + *CredentialUpdateProperties `json:"properties,omitempty"` +} + +// CredentialUpdateProperties is the properties of the Update credential +type CredentialUpdateProperties struct { + UserName *string `json:"userName,omitempty"` + Password *string `json:"password,omitempty"` + Description *string `json:"description,omitempty"` +} + +// DscCompilationJob is definition of the Dsc Compilation job. +type DscCompilationJob struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *DscCompilationJobProperties `json:"properties,omitempty"` +} + +// DscCompilationJobCreateParameters is the parameters supplied to the create +// compilation job operation. +type DscCompilationJobCreateParameters struct { + *DscCompilationJobCreateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// DscCompilationJobCreateProperties is the parameters supplied to the create +// compilation job operation. +type DscCompilationJobCreateProperties struct { + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// DscCompilationJobListResult is the response model for the list job +// operation. +type DscCompilationJobListResult struct { + autorest.Response `json:"-"` + Value *[]DscCompilationJob `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscCompilationJobListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscCompilationJobListResult) DscCompilationJobListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscCompilationJobProperties is definition of Dsc Compilation job properties. +type DscCompilationJobProperties struct { + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + StartedBy *string `json:"startedBy,omitempty"` + JobID *uuid.UUID `json:"jobId,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Status JobStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Exception *string `json:"exception,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// DscConfiguration is definition of the configuration type. +type DscConfiguration struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *DscConfigurationProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// DscConfigurationAssociationProperty is the Dsc configuration property +// associated with the entity. +type DscConfigurationAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// DscConfigurationCreateOrUpdateParameters is the parameters supplied to the +// create or update configuration operation. +type DscConfigurationCreateOrUpdateParameters struct { + *DscConfigurationCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// DscConfigurationCreateOrUpdateProperties is the properties to create or +// update configuration. +type DscConfigurationCreateOrUpdateProperties struct { + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + Source *ContentSource `json:"source,omitempty"` + Parameters *map[string]*DscConfigurationParameter `json:"parameters,omitempty"` + Description *string `json:"description,omitempty"` +} + +// DscConfigurationListResult is the response model for the list configuration +// operation. +type DscConfigurationListResult struct { + autorest.Response `json:"-"` + Value *[]DscConfiguration `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscConfigurationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscConfigurationListResult) DscConfigurationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscConfigurationParameter is definition of the configuration parameter type. +type DscConfigurationParameter struct { + Type *string `json:"type,omitempty"` + IsMandatory *bool `json:"isMandatory,omitempty"` + Position *int32 `json:"position,omitempty"` + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// DscConfigurationProperties is definition of the configuration property type. +type DscConfigurationProperties struct { + ProvisioningState DscConfigurationProvisioningState `json:"provisioningState,omitempty"` + JobCount *int32 `json:"jobCount,omitempty"` + Parameters *map[string]*DscConfigurationParameter `json:"parameters,omitempty"` + Source *ContentSource `json:"source,omitempty"` + State DscConfigurationState `json:"state,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// DscMetaConfiguration is definition of the DSC Meta Configuration. +type DscMetaConfiguration struct { + ConfigurationModeFrequencyMins *int32 `json:"configurationModeFrequencyMins,omitempty"` + RebootNodeIfNeeded *bool `json:"rebootNodeIfNeeded,omitempty"` + ConfigurationMode *string `json:"configurationMode,omitempty"` + ActionAfterReboot *string `json:"actionAfterReboot,omitempty"` + CertificateID *string `json:"certificateId,omitempty"` + RefreshFrequencyMins *int32 `json:"refreshFrequencyMins,omitempty"` + AllowModuleOverwrite *bool `json:"allowModuleOverwrite,omitempty"` +} + +// DscNode is definition of the dsc node type. +type DscNode struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + LastSeen *date.Time `json:"lastSeen,omitempty"` + RegistrationTime *date.Time `json:"registrationTime,omitempty"` + IP *string `json:"ip,omitempty"` + AccountID *string `json:"accountId,omitempty"` + NodeConfiguration *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` + Status *string `json:"status,omitempty"` + NodeID *string `json:"nodeId,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// DscNodeConfiguration is definition of the dsc node configuration. +type DscNodeConfiguration struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` + ID *string `json:"id,omitempty"` +} + +// DscNodeConfigurationAssociationProperty is the dsc nodeconfiguration +// property associated with the entity. +type DscNodeConfigurationAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// DscNodeConfigurationCreateOrUpdateParameters is the parameters supplied to +// the create or update node configuration operation. +type DscNodeConfigurationCreateOrUpdateParameters struct { + Source *ContentSource `json:"source,omitempty"` + Name *string `json:"name,omitempty"` + Configuration *DscConfigurationAssociationProperty `json:"configuration,omitempty"` +} + +// DscNodeConfigurationListResult is the response model for the list job +// operation. +type DscNodeConfigurationListResult struct { + autorest.Response `json:"-"` + Value *[]DscNodeConfiguration `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeConfigurationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscNodeConfigurationListResult) DscNodeConfigurationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscNodeListResult is the response model for the list dsc nodes operation. +type DscNodeListResult struct { + autorest.Response `json:"-"` + Value *[]DscNode `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscNodeListResult) DscNodeListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscNodeReport is definition of the dsc node report type. +type DscNodeReport struct { + autorest.Response `json:"-"` + EndTime *date.Time `json:"endTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + Type *string `json:"type,omitempty"` + ReportID *string `json:"reportId,omitempty"` + Status *string `json:"status,omitempty"` + RefreshMode *string `json:"refreshMode,omitempty"` + RebootRequested *string `json:"rebootRequested,omitempty"` + ReportFormatVersion *string `json:"reportFormatVersion,omitempty"` + ConfigurationVersion *string `json:"configurationVersion,omitempty"` + ID *string `json:"id,omitempty"` + Errors *[]DscReportError `json:"errors,omitempty"` + Resources *[]DscReportResource `json:"resources,omitempty"` + MetaConfiguration *DscMetaConfiguration `json:"metaConfiguration,omitempty"` + HostName *string `json:"hostName,omitempty"` + IPV4Addresses *[]string `json:"iPV4Addresses,omitempty"` + IPV6Addresses *[]string `json:"iPV6Addresses,omitempty"` + NumberOfResources *int32 `json:"numberOfResources,omitempty"` + RawErrors *string `json:"rawErrors,omitempty"` +} + +// DscNodeReportListResult is the response model for the list dsc nodes +// operation. +type DscNodeReportListResult struct { + autorest.Response `json:"-"` + Value *[]DscNodeReport `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DscNodeReportListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client DscNodeReportListResult) DscNodeReportListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// DscNodeUpdateParameters is the parameters supplied to the update dsc node +// operation. +type DscNodeUpdateParameters struct { + NodeID *string `json:"nodeId,omitempty"` + NodeConfiguration *DscNodeConfigurationAssociationProperty `json:"nodeConfiguration,omitempty"` +} + +// DscReportError is definition of the dsc node report error type. +type DscReportError struct { + ErrorSource *string `json:"errorSource,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Locale *string `json:"locale,omitempty"` + ErrorDetails *string `json:"errorDetails,omitempty"` +} + +// DscReportResource is definition of the DSC Report Resource. +type DscReportResource struct { + ResourceID *string `json:"resourceId,omitempty"` + SourceInfo *string `json:"sourceInfo,omitempty"` + DependsOn *[]DscReportResourceNavigation `json:"dependsOn,omitempty"` + ModuleName *string `json:"moduleName,omitempty"` + ModuleVersion *string `json:"moduleVersion,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + Error *string `json:"error,omitempty"` + Status *string `json:"status,omitempty"` + DurationInSeconds *float64 `json:"durationInSeconds,omitempty"` + StartDate *date.Time `json:"startDate,omitempty"` +} + +// DscReportResourceNavigation is navigation for DSC Report Resource. +type DscReportResourceNavigation struct { + ResourceID *string `json:"resourceId,omitempty"` +} + +// ErrorResponse is error response of an operation failure +type ErrorResponse struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// FieldDefinition is definition of the connection fields. +type FieldDefinition struct { + IsEncrypted *bool `json:"isEncrypted,omitempty"` + IsOptional *bool `json:"isOptional,omitempty"` + Type *string `json:"type,omitempty"` +} + +// HybridRunbookWorker is definition of hybrid runbook worker. +type HybridRunbookWorker struct { + Name *string `json:"name,omitempty"` + IP *string `json:"ip,omitempty"` + RegistrationTime *date.Time `json:"registrationTime,omitempty"` +} + +// HybridRunbookWorkerGroup is definition of hybrid runbook worker group. +type HybridRunbookWorkerGroup struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + HybridRunbookWorkers *[]HybridRunbookWorker `json:"hybridRunbookWorkers,omitempty"` + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` +} + +// HybridRunbookWorkerGroupsListResult is the response model for the list +// hybrid runbook worker groups. +type HybridRunbookWorkerGroupsListResult struct { + autorest.Response `json:"-"` + Value *[]HybridRunbookWorkerGroup `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// HybridRunbookWorkerGroupsListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client HybridRunbookWorkerGroupsListResult) HybridRunbookWorkerGroupsListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// HybridRunbookWorkerGroupUpdateParameters is parameters supplied to the +// update operation. +type HybridRunbookWorkerGroupUpdateParameters struct { + Credential *RunAsCredentialAssociationProperty `json:"credential,omitempty"` +} + +// Job is definition of the job. +type Job struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *JobProperties `json:"properties,omitempty"` +} + +// JobCreateParameters is the parameters supplied to the create job operation. +type JobCreateParameters struct { + *JobCreateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// JobCreateProperties is the parameters supplied to the create job operation. +type JobCreateProperties struct { + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + RunOn *string `json:"runOn,omitempty"` +} + +// JobListResult is the response model for the list job operation. +type JobListResult struct { + autorest.Response `json:"-"` + Value *[]Job `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobListResult) JobListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobProperties is definition of job properties. +type JobProperties struct { + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + StartedBy *string `json:"startedBy,omitempty"` + RunOn *string `json:"runOn,omitempty"` + JobID *uuid.UUID `json:"jobId,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Status JobStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Exception *string `json:"exception,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// JobSchedule is definition of the job schedule. +type JobSchedule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *JobScheduleProperties `json:"properties,omitempty"` +} + +// JobScheduleCreateParameters is the parameters supplied to the create job +// schedule operation. +type JobScheduleCreateParameters struct { + *JobScheduleCreateProperties `json:"properties,omitempty"` +} + +// JobScheduleCreateProperties is the parameters supplied to the create job +// schedule operation. +type JobScheduleCreateProperties struct { + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// JobScheduleListResult is the response model for the list job schedule +// operation. +type JobScheduleListResult struct { + autorest.Response `json:"-"` + Value *[]JobSchedule `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobScheduleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobScheduleListResult) JobScheduleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobScheduleProperties is definition of job schedule parameters. +type JobScheduleProperties struct { + JobScheduleID *string `json:"jobScheduleId,omitempty"` + Schedule *ScheduleAssociationProperty `json:"schedule,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// JobStream is definition of the job stream. +type JobStream struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + *JobStreamProperties `json:"properties,omitempty"` +} + +// JobStreamListResult is the response model for the list job stream operation. +type JobStreamListResult struct { + autorest.Response `json:"-"` + Value *[]JobStream `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobStreamListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobStreamListResult) JobStreamListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobStreamProperties is definition of the job stream. +type JobStreamProperties struct { + JobStreamID *string `json:"jobStreamId,omitempty"` + Time *date.Time `json:"time,omitempty"` + StreamType JobStreamType `json:"streamType,omitempty"` + StreamText *string `json:"streamText,omitempty"` + Summary *string `json:"summary,omitempty"` + Value *map[string]*map[string]interface{} `json:"value,omitempty"` +} + +// Module is definition of the module type. +type Module struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ModuleProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// ModuleCreateOrUpdateParameters is the parameters supplied to the create or +// update module operation. +type ModuleCreateOrUpdateParameters struct { + *ModuleCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ModuleCreateOrUpdateProperties is the parameters supplied to the create or +// update module properties. +type ModuleCreateOrUpdateProperties struct { + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// ModuleErrorInfo is definition of the module error info type. +type ModuleErrorInfo struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ModuleListResult is the response model for the list module operation. +type ModuleListResult struct { + autorest.Response `json:"-"` + Value *[]Module `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ModuleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ModuleListResult) ModuleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ModuleProperties is definition of the module property type. +type ModuleProperties struct { + IsGlobal *bool `json:"isGlobal,omitempty"` + Version *string `json:"version,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + ActivityCount *int32 `json:"activityCount,omitempty"` + ProvisioningState ModuleProvisioningState `json:"provisioningState,omitempty"` + ContentLink *ContentLink `json:"contentLink,omitempty"` + Error *ModuleErrorInfo `json:"error,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ModuleUpdateParameters is the parameters supplied to the update module +// operation. +type ModuleUpdateParameters struct { + *ModuleUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ModuleUpdateProperties is the parameters supplied to the update properties. +type ModuleUpdateProperties struct { + ContentLink *ContentLink `json:"contentLink,omitempty"` +} + +// Operation is automation REST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is provider, Resource and Operation values +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult is the response model for the list of Automation +// operations +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` +} + +// ReadCloser is +type ReadCloser struct { + autorest.Response `json:"-"` + Value *io.ReadCloser `json:"value,omitempty"` +} + +// Resource is the Resource definition. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RunAsCredentialAssociationProperty is definition of runas credential to use +// for hybrid worker. +type RunAsCredentialAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// Runbook is definition of the runbook type. +type Runbook struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *RunbookProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// RunbookAssociationProperty is the runbook property associated with the +// entity. +type RunbookAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// RunbookCreateOrUpdateParameters is the parameters supplied to the create or +// update runbook operation. +type RunbookCreateOrUpdateParameters struct { + *RunbookCreateOrUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RunbookCreateOrUpdateProperties is the parameters supplied to the create or +// update runbook properties. +type RunbookCreateOrUpdateProperties struct { + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + Draft *RunbookDraft `json:"draft,omitempty"` + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + Description *string `json:"description,omitempty"` + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// RunbookDraft is definition of the runbook type. +type RunbookDraft struct { + autorest.Response `json:"-"` + InEdit *bool `json:"inEdit,omitempty"` + DraftContentLink *ContentLink `json:"draftContentLink,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Parameters *map[string]*RunbookParameter `json:"parameters,omitempty"` + OutputTypes *[]string `json:"outputTypes,omitempty"` +} + +// RunbookDraftUndoEditResult is the response model for the undoedit runbook +// operation. +type RunbookDraftUndoEditResult struct { + autorest.Response `json:"-"` + StatusCode HTTPStatusCode `json:"statusCode,omitempty"` + RequestID *string `json:"requestId,omitempty"` +} + +// RunbookListResult is the response model for the list runbook operation. +type RunbookListResult struct { + autorest.Response `json:"-"` + Value *[]Runbook `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RunbookListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RunbookListResult) RunbookListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RunbookParameter is definition of the runbook parameter type. +type RunbookParameter struct { + Type *string `json:"type,omitempty"` + IsMandatory *bool `json:"isMandatory,omitempty"` + Position *int32 `json:"position,omitempty"` + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// RunbookProperties is definition of the runbook property type. +type RunbookProperties struct { + RunbookType RunbookTypeEnum `json:"runbookType,omitempty"` + PublishContentLink *ContentLink `json:"publishContentLink,omitempty"` + State RunbookState `json:"state,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` + JobCount *int32 `json:"jobCount,omitempty"` + Parameters *map[string]*RunbookParameter `json:"parameters,omitempty"` + OutputTypes *[]string `json:"outputTypes,omitempty"` + Draft *RunbookDraft `json:"draft,omitempty"` + ProvisioningState RunbookProvisioningState `json:"provisioningState,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// RunbookUpdateParameters is the parameters supplied to the update runbook +// operation. +type RunbookUpdateParameters struct { + *RunbookUpdateProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RunbookUpdateProperties is the parameters supplied to the update runbook +// properties. +type RunbookUpdateProperties struct { + Description *string `json:"description,omitempty"` + LogVerbose *bool `json:"logVerbose,omitempty"` + LogProgress *bool `json:"logProgress,omitempty"` + LogActivityTrace *int32 `json:"logActivityTrace,omitempty"` +} + +// Schedule is definition of the schedule. +type Schedule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *ScheduleProperties `json:"properties,omitempty"` +} + +// ScheduleAssociationProperty is the schedule property associated with the +// entity. +type ScheduleAssociationProperty struct { + Name *string `json:"name,omitempty"` +} + +// ScheduleCreateOrUpdateParameters is the parameters supplied to the create or +// update schedule operation. +type ScheduleCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ScheduleCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// ScheduleCreateOrUpdateProperties is the parameters supplied to the create or +// update schedule operation. +type ScheduleCreateOrUpdateProperties struct { + Description *string `json:"description,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + Interval *map[string]interface{} `json:"interval,omitempty"` + Frequency ScheduleFrequency `json:"frequency,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` +} + +// ScheduleListResult is the response model for the list schedule operation. +type ScheduleListResult struct { + autorest.Response `json:"-"` + Value *[]Schedule `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ScheduleListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ScheduleListResult) ScheduleListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ScheduleProperties is definition of schedule parameters. +type ScheduleProperties struct { + StartTime *date.Time `json:"startTime,omitempty"` + StartTimeOffsetMinutes *float64 `json:"startTimeOffsetMinutes,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + ExpiryTimeOffsetMinutes *float64 `json:"expiryTimeOffsetMinutes,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + NextRun *date.Time `json:"nextRun,omitempty"` + NextRunOffsetMinutes *float64 `json:"nextRunOffsetMinutes,omitempty"` + Interval *map[string]interface{} `json:"interval,omitempty"` + Frequency ScheduleFrequency `json:"frequency,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + AdvancedSchedule *AdvancedSchedule `json:"advancedSchedule,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// ScheduleUpdateParameters is the parameters supplied to the update schedule +// operation. +type ScheduleUpdateParameters struct { + Name *string `json:"name,omitempty"` + *ScheduleUpdateProperties `json:"properties,omitempty"` +} + +// ScheduleUpdateProperties is the parameters supplied to the update schedule +// operation. +type ScheduleUpdateProperties struct { + Description *string `json:"description,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` +} + +// Sku is the account SKU. +type Sku struct { + Name SkuNameEnum `json:"name,omitempty"` + Family *string `json:"family,omitempty"` + Capacity *int32 `json:"capacity,omitempty"` +} + +// Statistics is definition of the statistic. +type Statistics struct { + CounterProperty *string `json:"counterProperty,omitempty"` + CounterValue *int64 `json:"counterValue,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + ID *string `json:"id,omitempty"` +} + +// StatisticsListResult is the response model for the list statistics +// operation. +type StatisticsListResult struct { + autorest.Response `json:"-"` + Value *[]Statistics `json:"value,omitempty"` +} + +// String is +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` +} + +// TestJob is definition of the test job. +type TestJob struct { + autorest.Response `json:"-"` + CreationTime *date.Time `json:"creationTime,omitempty"` + Status *string `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` + RunOn *string `json:"runOn,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Exception *string `json:"exception,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + LastStatusModifiedTime *date.Time `json:"lastStatusModifiedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` +} + +// TestJobCreateParameters is the parameters supplied to the create test job +// operation. +type TestJobCreateParameters struct { + RunbookName *string `json:"runbookName,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + RunOn *string `json:"runOn,omitempty"` +} + +// TypeField is information about a field of a type. +type TypeField struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// TypeFieldListResult is the response model for the list fields operation. +type TypeFieldListResult struct { + autorest.Response `json:"-"` + Value *[]TypeField `json:"value,omitempty"` +} + +// Usage is definition of Usage. +type Usage struct { + ID *string `json:"id,omitempty"` + Name *UsageCounterName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` + CurrentValue *float64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + ThrottleStatus *string `json:"throttleStatus,omitempty"` +} + +// UsageCounterName is definition of usage counter name. +type UsageCounterName struct { + Value *string `json:"value,omitempty"` + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// UsageListResult is the response model for the get usage operation. +type UsageListResult struct { + autorest.Response `json:"-"` + Value *[]Usage `json:"value,omitempty"` +} + +// Variable is definition of the varible. +type Variable struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *VariableProperties `json:"properties,omitempty"` +} + +// VariableCreateOrUpdateParameters is the parameters supplied to the create or +// update variable operation. +type VariableCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *VariableCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// VariableCreateOrUpdateProperties is the properties of the create variable +// operation. +type VariableCreateOrUpdateProperties struct { + Value *string `json:"value,omitempty"` + Description *string `json:"description,omitempty"` + IsEncrypted *bool `json:"isEncrypted,omitempty"` +} + +// VariableListResult is the response model for the list variables operation. +type VariableListResult struct { + autorest.Response `json:"-"` + Value *[]Variable `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// VariableListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client VariableListResult) VariableListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// VariableProperties is definition of the varible properties +type VariableProperties struct { + Value *string `json:"value,omitempty"` + IsEncrypted *bool `json:"isEncrypted,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// VariableUpdateParameters is the parameters supplied to the update variable +// operation. +type VariableUpdateParameters struct { + Name *string `json:"name,omitempty"` + *VariableUpdateProperties `json:"properties,omitempty"` +} + +// VariableUpdateProperties is the properties of the update variable +type VariableUpdateProperties struct { + Value *string `json:"value,omitempty"` + Description *string `json:"description,omitempty"` +} + +// Webhook is definition of the webhook type. +type Webhook struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + *WebhookProperties `json:"properties,omitempty"` +} + +// WebhookCreateOrUpdateParameters is the parameters supplied to the create or +// update webhook operation. +type WebhookCreateOrUpdateParameters struct { + Name *string `json:"name,omitempty"` + *WebhookCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// WebhookCreateOrUpdateProperties is the properties of the create webhook +// operation. +type WebhookCreateOrUpdateProperties struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + URI *string `json:"uri,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` +} + +// WebhookListResult is the response model for the list webhook operation. +type WebhookListResult struct { + autorest.Response `json:"-"` + Value *[]Webhook `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// WebhookListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client WebhookListResult) WebhookListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// WebhookProperties is definition of the webhook properties +type WebhookProperties struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + URI *string `json:"uri,omitempty"` + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + LastInvokedTime *date.Time `json:"lastInvokedTime,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + Runbook *RunbookAssociationProperty `json:"runbook,omitempty"` + RunOn *string `json:"runOn,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"` + Description *string `json:"description,omitempty"` +} + +// WebhookUpdateParameters is the parameters supplied to the update webhook +// operation. +type WebhookUpdateParameters struct { + Name *string `json:"name,omitempty"` + *WebhookUpdateProperties `json:"properties,omitempty"` +} + +// WebhookUpdateProperties is the properties of the update webhook. +type WebhookUpdateProperties struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + RunOn *string `json:"runOn,omitempty"` + Parameters *map[string]*string `json:"parameters,omitempty"` + Description *string `json:"description,omitempty"` +} diff --git a/arm/automation/module.go b/arm/automation/module.go new file mode 100644 index 000000000000..225b0a4957e1 --- /dev/null +++ b/arm/automation/module.go @@ -0,0 +1,443 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ModuleClient is the composite Swagger json for Azure Automation Client +type ModuleClient struct { + ManagementClient +} + +// NewModuleClient creates an instance of the ModuleClient client. +func NewModuleClient(subscriptionID string) ModuleClient { + return NewModuleClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewModuleClientWithBaseURI creates an instance of the ModuleClient client. +func NewModuleClientWithBaseURI(baseURI string, subscriptionID string) ModuleClient { + return ModuleClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or Update the module identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. parameters is the +// create or update parameters for module. +func (client ModuleClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ModuleCreateOrUpdateProperties.ContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ModuleClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ModuleClient) CreateOrUpdateResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the module by name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the module name. +func (client ModuleClient) Delete(resourceGroupName string, automationAccountName string, moduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ModuleClient) DeletePreparer(resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ModuleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the module identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the module name. +func (client ModuleClient) Get(resourceGroupName string, automationAccountName string, moduleName string) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, moduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ModuleClient) GetPreparer(resourceGroupName string, automationAccountName string, moduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ModuleClient) GetResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of modules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ModuleClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ModuleListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ModuleClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ModuleClient) ListByAutomationAccountResponder(resp *http.Response) (result ModuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ModuleClient) ListByAutomationAccountNextResults(lastResults ModuleListResult) (result ModuleListResult, err error) { + req, err := lastResults.ModuleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the module identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. parameters is the +// update parameters for module. +func (client ModuleClient) Update(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (result Module, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ModuleClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, moduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ModuleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ModuleClient) UpdatePreparer(resourceGroupName string, automationAccountName string, moduleName string, parameters ModuleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ModuleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ModuleClient) UpdateResponder(resp *http.Response) (result Module, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/nodereports.go b/arm/automation/nodereports.go new file mode 100644 index 000000000000..ad9f6acb3d48 --- /dev/null +++ b/arm/automation/nodereports.go @@ -0,0 +1,292 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// NodeReportsClient is the composite Swagger json for Azure Automation Client +type NodeReportsClient struct { + ManagementClient +} + +// NewNodeReportsClient creates an instance of the NodeReportsClient client. +func NewNodeReportsClient(subscriptionID string) NodeReportsClient { + return NewNodeReportsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNodeReportsClientWithBaseURI creates an instance of the NodeReportsClient +// client. +func NewNodeReportsClientWithBaseURI(baseURI string, subscriptionID string) NodeReportsClient { + return NodeReportsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the Dsc node report data by node id and report id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the Dsc node id. reportID is the report +// id. +func (client NodeReportsClient) Get(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result DscNodeReport, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.NodeReportsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NodeReportsClient) GetPreparer(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetResponder(resp *http.Response) (result DscNodeReport, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the Dsc node reports by node id and report id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the Dsc node id. reportID is the report +// id. +func (client NodeReportsClient) GetContent(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.NodeReportsClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, nodeID, reportID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client NodeReportsClient) GetContentPreparer(resourceGroupName string, automationAccountName string, nodeID string, reportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "reportId": autorest.Encode("path", reportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByNode retrieve the Dsc node report list by node id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. nodeID is the parameters supplied to the list +// operation. filter is the filter to apply on the operation. +func (client NodeReportsClient) ListByNode(resourceGroupName string, automationAccountName string, nodeID string, filter string) (result DscNodeReportListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.NodeReportsClient", "ListByNode") + } + + req, err := client.ListByNodePreparer(resourceGroupName, automationAccountName, nodeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure sending request") + return + } + + result, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure responding to request") + } + + return +} + +// ListByNodePreparer prepares the ListByNode request. +func (client NodeReportsClient) ListByNodePreparer(resourceGroupName string, automationAccountName string, nodeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "nodeId": autorest.Encode("path", nodeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByNodeSender sends the ListByNode request. The method will close the +// http.Response Body if it receives an error. +func (client NodeReportsClient) ListByNodeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByNodeResponder handles the response to the ListByNode request. The method always +// closes the http.Response Body. +func (client NodeReportsClient) ListByNodeResponder(resp *http.Response) (result DscNodeReportListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByNodeNextResults retrieves the next set of results, if any. +func (client NodeReportsClient) ListByNodeNextResults(lastResults DscNodeReportListResult) (result DscNodeReportListResult, err error) { + req, err := lastResults.DscNodeReportListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByNodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure sending next results request") + } + + result, err = client.ListByNodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.NodeReportsClient", "ListByNode", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/objectdatatypes.go b/arm/automation/objectdatatypes.go new file mode 100644 index 000000000000..0a0952fb2da3 --- /dev/null +++ b/arm/automation/objectdatatypes.go @@ -0,0 +1,194 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ObjectDataTypesClient is the composite Swagger json for Azure Automation +// Client +type ObjectDataTypesClient struct { + ManagementClient +} + +// NewObjectDataTypesClient creates an instance of the ObjectDataTypesClient +// client. +func NewObjectDataTypesClient(subscriptionID string) ObjectDataTypesClient { + return NewObjectDataTypesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewObjectDataTypesClientWithBaseURI creates an instance of the +// ObjectDataTypesClient client. +func NewObjectDataTypesClientWithBaseURI(baseURI string, subscriptionID string) ObjectDataTypesClient { + return ObjectDataTypesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListFieldsByModuleAndType retrieve a list of fields of a given type +// identified by module name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. moduleName is the name of module. typeName is the +// name of type. +func (client ObjectDataTypesClient) ListFieldsByModuleAndType(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType") + } + + req, err := client.ListFieldsByModuleAndTypePreparer(resourceGroupName, automationAccountName, moduleName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByModuleAndTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByModuleAndTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByModuleAndType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByModuleAndTypePreparer prepares the ListFieldsByModuleAndType request. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypePreparer(resourceGroupName string, automationAccountName string, moduleName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "moduleName": autorest.Encode("path", moduleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListFieldsByModuleAndTypeSender sends the ListFieldsByModuleAndType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListFieldsByModuleAndTypeResponder handles the response to the ListFieldsByModuleAndType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByModuleAndTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFieldsByType retrieve a list of fields of a given type across all +// accessible modules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. typeName is the name of type. +func (client ObjectDataTypesClient) ListFieldsByType(resourceGroupName string, automationAccountName string, typeName string) (result TypeFieldListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ObjectDataTypesClient", "ListFieldsByType") + } + + req, err := client.ListFieldsByTypePreparer(resourceGroupName, automationAccountName, typeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", nil, "Failure preparing request") + return + } + + resp, err := client.ListFieldsByTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure sending request") + return + } + + result, err = client.ListFieldsByTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ObjectDataTypesClient", "ListFieldsByType", resp, "Failure responding to request") + } + + return +} + +// ListFieldsByTypePreparer prepares the ListFieldsByType request. +func (client ObjectDataTypesClient) ListFieldsByTypePreparer(resourceGroupName string, automationAccountName string, typeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "typeName": autorest.Encode("path", typeName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListFieldsByTypeSender sends the ListFieldsByType request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectDataTypesClient) ListFieldsByTypeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListFieldsByTypeResponder handles the response to the ListFieldsByType request. The method always +// closes the http.Response Body. +func (client ObjectDataTypesClient) ListFieldsByTypeResponder(resp *http.Response) (result TypeFieldListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/operations.go b/arm/automation/operations.go new file mode 100644 index 000000000000..a70339b7a763 --- /dev/null +++ b/arm/automation/operations.go @@ -0,0 +1,98 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the composite Swagger json for Azure Automation Client +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Automation REST API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Automation/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/runbook.go b/arm/automation/runbook.go new file mode 100644 index 000000000000..52a522bea753 --- /dev/null +++ b/arm/automation/runbook.go @@ -0,0 +1,523 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// RunbookClient is the composite Swagger json for Azure Automation Client +type RunbookClient struct { + ManagementClient +} + +// NewRunbookClient creates an instance of the RunbookClient client. +func NewRunbookClient(subscriptionID string) RunbookClient { + return NewRunbookClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRunbookClientWithBaseURI creates an instance of the RunbookClient client. +func NewRunbookClientWithBaseURI(baseURI string, subscriptionID string) RunbookClient { + return RunbookClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. parameters is the +// create or update parameters for runbook. Provide either content link for a +// published runbook or draft, not both. +func (client RunbookClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.Draft.DraftContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.RunbookCreateOrUpdateProperties.PublishContentLink.ContentHash.Value", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RunbookClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RunbookClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusBadRequest), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete delete the runbook by name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookClient) Delete(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RunbookClient) DeletePreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RunbookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookClient) Get(resourceGroupName string, automationAccountName string, runbookName string) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookClient) GetContent(resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookClient) GetContentPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of runbooks. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client RunbookClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result RunbookListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client RunbookClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client RunbookClient) ListByAutomationAccountResponder(resp *http.Response) (result RunbookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client RunbookClient) ListByAutomationAccountNextResults(lastResults RunbookListResult) (result RunbookListResult, err error) { + req, err := lastResults.RunbookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. parameters is the +// update parameters for runbook. +func (client RunbookClient) Update(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (result Runbook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client RunbookClient) UpdatePreparer(resourceGroupName string, automationAccountName string, runbookName string, parameters RunbookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RunbookClient) UpdateResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/runbookdraft.go b/arm/automation/runbookdraft.go new file mode 100644 index 000000000000..d3679ee4370f --- /dev/null +++ b/arm/automation/runbookdraft.go @@ -0,0 +1,447 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "io" + "net/http" +) + +// RunbookDraftClient is the composite Swagger json for Azure Automation Client +type RunbookDraftClient struct { + ManagementClient +} + +// NewRunbookDraftClient creates an instance of the RunbookDraftClient client. +func NewRunbookDraftClient(subscriptionID string) RunbookDraftClient { + return NewRunbookDraftClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRunbookDraftClientWithBaseURI creates an instance of the +// RunbookDraftClient client. +func NewRunbookDraftClientWithBaseURI(baseURI string, subscriptionID string) RunbookDraftClient { + return RunbookDraftClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates the runbook draft with runbookStream as its content. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. runbookContent is +// the runbook draft content. runbookContent will be closed upon successful +// return. Callers should ensure closure when receiving an error. +func (client RunbookDraftClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, runbookName, runbookContent, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RunbookDraftClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, runbookName string, runbookContent io.ReadCloser, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithFile(runbookContent), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the runbook draft identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookDraftClient) Get(resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraft, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RunbookDraftClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetResponder(resp *http.Response) (result RunbookDraft, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetContent retrieve the content of runbook draft identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookDraftClient) GetContent(resourceGroupName string, automationAccountName string, runbookName string) (result ReadCloser, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "GetContent") + } + + req, err := client.GetContentPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", nil, "Failure preparing request") + return + } + + resp, err := client.GetContentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure sending request") + return + } + + result, err = client.GetContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "GetContent", resp, "Failure responding to request") + } + + return +} + +// GetContentPreparer prepares the GetContent request. +func (client RunbookDraftClient) GetContentPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetContentSender sends the GetContent request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) GetContentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetContentResponder handles the response to the GetContent request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// Publish publish runbook draft. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the parameters supplied to the +// publish runbook operation. +func (client RunbookDraftClient) Publish(resourceGroupName string, automationAccountName string, runbookName string, cancel <-chan struct{}) (<-chan Runbook, <-chan error) { + resultChan := make(chan Runbook, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "Publish") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Runbook + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PublishPreparer(resourceGroupName, automationAccountName, runbookName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", nil, "Failure preparing request") + return + } + + resp, err := client.PublishSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", resp, "Failure sending request") + return + } + + result, err = client.PublishResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "Publish", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PublishPreparer prepares the Publish request. +func (client RunbookDraftClient) PublishPreparer(resourceGroupName string, automationAccountName string, runbookName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/publish", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PublishSender sends the Publish request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) PublishSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PublishResponder handles the response to the Publish request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) PublishResponder(resp *http.Response) (result Runbook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UndoEdit retrieve the runbook identified by runbook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client RunbookDraftClient) UndoEdit(resourceGroupName string, automationAccountName string, runbookName string) (result RunbookDraftUndoEditResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.RunbookDraftClient", "UndoEdit") + } + + req, err := client.UndoEditPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", nil, "Failure preparing request") + return + } + + resp, err := client.UndoEditSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure sending request") + return + } + + result, err = client.UndoEditResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.RunbookDraftClient", "UndoEdit", resp, "Failure responding to request") + } + + return +} + +// UndoEditPreparer prepares the UndoEdit request. +func (client RunbookDraftClient) UndoEditPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UndoEditSender sends the UndoEdit request. The method will close the +// http.Response Body if it receives an error. +func (client RunbookDraftClient) UndoEditSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UndoEditResponder handles the response to the UndoEdit request. The method always +// closes the http.Response Body. +func (client RunbookDraftClient) UndoEditResponder(resp *http.Response) (result RunbookDraftUndoEditResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/schedule.go b/arm/automation/schedule.go new file mode 100644 index 000000000000..9a98147d6976 --- /dev/null +++ b/arm/automation/schedule.go @@ -0,0 +1,439 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ScheduleClient is the composite Swagger json for Azure Automation Client +type ScheduleClient struct { + ManagementClient +} + +// NewScheduleClient creates an instance of the ScheduleClient client. +func NewScheduleClient(subscriptionID string) ScheduleClient { + return NewScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScheduleClientWithBaseURI creates an instance of the ScheduleClient +// client. +func NewScheduleClientWithBaseURI(baseURI string, subscriptionID string) ScheduleClient { + return ScheduleClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a schedule. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. parameters is +// the parameters supplied to the create or update schedule operation. +func (client ScheduleClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ScheduleCreateOrUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ScheduleCreateOrUpdateProperties.StartTime", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScheduleClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScheduleClient) CreateOrUpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusConflict), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the schedule identified by schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. +func (client ScheduleClient) Delete(resourceGroupName string, automationAccountName string, scheduleName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScheduleClient) DeletePreparer(resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScheduleClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the schedule identified by schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. +func (client ScheduleClient) Get(resourceGroupName string, automationAccountName string, scheduleName string) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, scheduleName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScheduleClient) GetPreparer(resourceGroupName string, automationAccountName string, scheduleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScheduleClient) GetResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of schedules. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client ScheduleClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result ScheduleListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client ScheduleClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client ScheduleClient) ListByAutomationAccountResponder(resp *http.Response) (result ScheduleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client ScheduleClient) ListByAutomationAccountNextResults(lastResults ScheduleListResult) (result ScheduleListResult, err error) { + req, err := lastResults.ScheduleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the schedule identified by schedule name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. scheduleName is the schedule name. parameters is +// the parameters supplied to the update schedule operation. +func (client ScheduleClient) Update(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.ScheduleClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, scheduleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.ScheduleClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ScheduleClient) UpdatePreparer(resourceGroupName string, automationAccountName string, scheduleName string, parameters ScheduleUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scheduleName": autorest.Encode("path", scheduleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduleClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ScheduleClient) UpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/statistics.go b/arm/automation/statistics.go new file mode 100644 index 000000000000..74d027ebe340 --- /dev/null +++ b/arm/automation/statistics.go @@ -0,0 +1,117 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// StatisticsClient is the composite Swagger json for Azure Automation Client +type StatisticsClient struct { + ManagementClient +} + +// NewStatisticsClient creates an instance of the StatisticsClient client. +func NewStatisticsClient(subscriptionID string) StatisticsClient { + return NewStatisticsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStatisticsClientWithBaseURI creates an instance of the StatisticsClient +// client. +func NewStatisticsClientWithBaseURI(baseURI string, subscriptionID string) StatisticsClient { + return StatisticsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByAutomationAccount retrieve the statistics for the account. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client StatisticsClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result StatisticsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.StatisticsClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.StatisticsClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client StatisticsClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client StatisticsClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client StatisticsClient) ListByAutomationAccountResponder(resp *http.Response) (result StatisticsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/testjobs.go b/arm/automation/testjobs.go new file mode 100644 index 000000000000..55a39599a1db --- /dev/null +++ b/arm/automation/testjobs.go @@ -0,0 +1,410 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// TestJobsClient is the composite Swagger json for Azure Automation Client +type TestJobsClient struct { + ManagementClient +} + +// NewTestJobsClient creates an instance of the TestJobsClient client. +func NewTestJobsClient(subscriptionID string) TestJobsClient { + return NewTestJobsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTestJobsClientWithBaseURI creates an instance of the TestJobsClient +// client. +func NewTestJobsClientWithBaseURI(baseURI string, subscriptionID string) TestJobsClient { + return TestJobsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a test job of the runbook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the parameters supplied to the +// create test job operation. parameters is the parameters supplied to the +// create test job operation. +func (client TestJobsClient) Create(resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RunbookName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Create") + } + + req, err := client.CreatePreparer(resourceGroupName, automationAccountName, runbookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TestJobsClient) CreatePreparer(resourceGroupName string, automationAccountName string, runbookName string, parameters TestJobCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TestJobsClient) CreateResponder(resp *http.Response) (result TestJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the test job for the specified runbook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Get(resourceGroupName string, automationAccountName string, runbookName string) (result TestJob, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobsClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobsClient) GetResponder(resp *http.Response) (result TestJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Resume resume the test job. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Resume(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Resume") + } + + req, err := client.ResumePreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Resume", resp, "Failure responding to request") + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client TestJobsClient) ResumePreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client TestJobsClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop the test job. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Stop(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Stop") + } + + req, err := client.StopPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client TestJobsClient) StopPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client TestJobsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Suspend suspend the test job. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. +func (client TestJobsClient) Suspend(resourceGroupName string, automationAccountName string, runbookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobsClient", "Suspend") + } + + req, err := client.SuspendPreparer(resourceGroupName, automationAccountName, runbookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Suspend", nil, "Failure preparing request") + return + } + + resp, err := client.SuspendSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Suspend", resp, "Failure sending request") + return + } + + result, err = client.SuspendResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobsClient", "Suspend", resp, "Failure responding to request") + } + + return +} + +// SuspendPreparer prepares the Suspend request. +func (client TestJobsClient) SuspendPreparer(resourceGroupName string, automationAccountName string, runbookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// SuspendSender sends the Suspend request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobsClient) SuspendSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// SuspendResponder handles the response to the Suspend request. The method always +// closes the http.Response Body. +func (client TestJobsClient) SuspendResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/arm/automation/testjobstreams.go b/arm/automation/testjobstreams.go new file mode 100644 index 000000000000..f5f608457c29 --- /dev/null +++ b/arm/automation/testjobstreams.go @@ -0,0 +1,221 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// TestJobStreamsClient is the composite Swagger json for Azure Automation +// Client +type TestJobStreamsClient struct { + ManagementClient +} + +// NewTestJobStreamsClient creates an instance of the TestJobStreamsClient +// client. +func NewTestJobStreamsClient(subscriptionID string) TestJobStreamsClient { + return NewTestJobStreamsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTestJobStreamsClientWithBaseURI creates an instance of the +// TestJobStreamsClient client. +func NewTestJobStreamsClientWithBaseURI(baseURI string, subscriptionID string) TestJobStreamsClient { + return TestJobStreamsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve a test job streams identified by runbook name and stream id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. jobStreamID is the +// job stream id. +func (client TestJobStreamsClient) Get(resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (result JobStream, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobStreamsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, runbookName, jobStreamID) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TestJobStreamsClient) GetPreparer(resourceGroupName string, automationAccountName string, runbookName string, jobStreamID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "jobStreamId": autorest.Encode("path", jobStreamID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) GetResponder(resp *http.Response) (result JobStream, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTestJob retrieve a list of test job streams identified by runbook +// name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. runbookName is the runbook name. filter is the +// filter to apply on the operation. +func (client TestJobStreamsClient) ListByTestJob(resourceGroupName string, automationAccountName string, runbookName string, filter string) (result JobStreamListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.TestJobStreamsClient", "ListByTestJob") + } + + req, err := client.ListByTestJobPreparer(resourceGroupName, automationAccountName, runbookName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure sending request") + return + } + + result, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure responding to request") + } + + return +} + +// ListByTestJobPreparer prepares the ListByTestJob request. +func (client TestJobStreamsClient) ListByTestJobPreparer(resourceGroupName string, automationAccountName string, runbookName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "runbookName": autorest.Encode("path", runbookName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByTestJobSender sends the ListByTestJob request. The method will close the +// http.Response Body if it receives an error. +func (client TestJobStreamsClient) ListByTestJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByTestJobResponder handles the response to the ListByTestJob request. The method always +// closes the http.Response Body. +func (client TestJobStreamsClient) ListByTestJobResponder(resp *http.Response) (result JobStreamListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTestJobNextResults retrieves the next set of results, if any. +func (client TestJobStreamsClient) ListByTestJobNextResults(lastResults JobStreamListResult) (result JobStreamListResult, err error) { + req, err := lastResults.JobStreamListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByTestJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure sending next results request") + } + + result, err = client.ListByTestJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.TestJobStreamsClient", "ListByTestJob", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/automation/usages.go b/arm/automation/usages.go new file mode 100644 index 000000000000..63057bebad69 --- /dev/null +++ b/arm/automation/usages.go @@ -0,0 +1,113 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// UsagesClient is the composite Swagger json for Azure Automation Client +type UsagesClient struct { + ManagementClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client. +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByAutomationAccount retrieve the usage for the account id. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client UsagesClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result UsageListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.UsagesClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.UsagesClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client UsagesClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client UsagesClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client UsagesClient) ListByAutomationAccountResponder(resp *http.Response) (result UsageListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/variable.go b/arm/automation/variable.go new file mode 100644 index 000000000000..22da1431d9f3 --- /dev/null +++ b/arm/automation/variable.go @@ -0,0 +1,438 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// VariableClient is the composite Swagger json for Azure Automation Client +type VariableClient struct { + ManagementClient +} + +// NewVariableClient creates an instance of the VariableClient client. +func NewVariableClient(subscriptionID string) VariableClient { + return NewVariableClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVariableClientWithBaseURI creates an instance of the VariableClient +// client. +func NewVariableClientWithBaseURI(baseURI string, subscriptionID string) VariableClient { + return VariableClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a variable. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the variable name. parameters is +// the parameters supplied to the create or update variable operation. +func (client VariableClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.VariableCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VariableClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, variableName string, parameters VariableCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VariableClient) CreateOrUpdateResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the variable. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the name of variable. +func (client VariableClient) Delete(resourceGroupName string, automationAccountName string, variableName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VariableClient) DeletePreparer(resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VariableClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve the variable identified by variable name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the name of variable. +func (client VariableClient) Get(resourceGroupName string, automationAccountName string, variableName string) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, variableName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VariableClient) GetPreparer(resourceGroupName string, automationAccountName string, variableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VariableClient) GetResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of variables. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client VariableClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string) (result VariableListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client VariableClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client VariableClient) ListByAutomationAccountResponder(resp *http.Response) (result VariableListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client VariableClient) ListByAutomationAccountNextResults(lastResults VariableListResult) (result VariableListResult, err error) { + req, err := lastResults.VariableListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update a variable. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. variableName is the variable name. parameters is +// the parameters supplied to the update variable operation. +func (client VariableClient) Update(resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (result Variable, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.VariableClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, variableName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.VariableClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VariableClient) UpdatePreparer(resourceGroupName string, automationAccountName string, variableName string, parameters VariableUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "variableName": autorest.Encode("path", variableName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VariableClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VariableClient) UpdateResponder(resp *http.Response) (result Variable, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/automation/version.go b/arm/automation/version.go new file mode 100644 index 000000000000..4cefcc1790ed --- /dev/null +++ b/arm/automation/version.go @@ -0,0 +1,29 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.0.0-beta arm-automation/" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.0.0-beta" +} diff --git a/arm/automation/webhook.go b/arm/automation/webhook.go new file mode 100644 index 000000000000..8b172c07278d --- /dev/null +++ b/arm/automation/webhook.go @@ -0,0 +1,512 @@ +package automation + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// WebhookClient is the composite Swagger json for Azure Automation Client +type WebhookClient struct { + ManagementClient +} + +// NewWebhookClient creates an instance of the WebhookClient client. +func NewWebhookClient(subscriptionID string) WebhookClient { + return NewWebhookClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWebhookClientWithBaseURI creates an instance of the WebhookClient client. +func NewWebhookClientWithBaseURI(baseURI string, subscriptionID string) WebhookClient { + return WebhookClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create the webhook identified by webhook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. parameters is the +// create or update parameters for webhook. +func (client WebhookClient) CreateOrUpdate(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WebhookCreateOrUpdateProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WebhookClient) CreateOrUpdatePreparer(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookCreateOrUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WebhookClient) CreateOrUpdateResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the webhook by name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. +func (client WebhookClient) Delete(resourceGroupName string, automationAccountName string, webhookName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WebhookClient) DeletePreparer(resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WebhookClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateURI generates a Uri for use in creating a webhook. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. +func (client WebhookClient) GenerateURI(resourceGroupName string, automationAccountName string) (result String, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "GenerateURI") + } + + req, err := client.GenerateURIPreparer(resourceGroupName, automationAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateURISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure sending request") + return + } + + result, err = client.GenerateURIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "GenerateURI", resp, "Failure responding to request") + } + + return +} + +// GenerateURIPreparer prepares the GenerateURI request. +func (client WebhookClient) GenerateURIPreparer(resourceGroupName string, automationAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GenerateURISender sends the GenerateURI request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GenerateURISender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GenerateURIResponder handles the response to the GenerateURI request. The method always +// closes the http.Response Body. +func (client WebhookClient) GenerateURIResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get retrieve the webhook identified by webhook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. +func (client WebhookClient) Get(resourceGroupName string, automationAccountName string, webhookName string) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, automationAccountName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WebhookClient) GetPreparer(resourceGroupName string, automationAccountName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WebhookClient) GetResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccount retrieve a list of webhooks. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. filter is the filter to apply on the operation. +func (client WebhookClient) ListByAutomationAccount(resourceGroupName string, automationAccountName string, filter string) (result WebhookListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "ListByAutomationAccount") + } + + req, err := client.ListByAutomationAccountPreparer(resourceGroupName, automationAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure responding to request") + } + + return +} + +// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request. +func (client WebhookClient) ListByAutomationAccountPreparer(resourceGroupName string, automationAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always +// closes the http.Response Body. +func (client WebhookClient) ListByAutomationAccountResponder(resp *http.Response) (result WebhookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAutomationAccountNextResults retrieves the next set of results, if any. +func (client WebhookClient) ListByAutomationAccountNextResults(lastResults WebhookListResult) (result WebhookListResult, err error) { + req, err := lastResults.WebhookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByAutomationAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure sending next results request") + } + + result, err = client.ListByAutomationAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "ListByAutomationAccount", resp, "Failure responding to next results request") + } + + return +} + +// Update update the webhook identified by webhook name. +// +// resourceGroupName is the resource group name. automationAccountName is the +// automation account name. webhookName is the webhook name. parameters is the +// update parameters for webhook. +func (client WebhookClient) Update(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "automation.WebhookClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, automationAccountName, webhookName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automation.WebhookClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WebhookClient) UpdatePreparer(resourceGroupName string, automationAccountName string, webhookName string, parameters WebhookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationAccountName": autorest.Encode("path", automationAccountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2015-10-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WebhookClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WebhookClient) UpdateResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/batch/account.go b/arm/batch/account.go index 1a2bc8db4ce3..9b8ad8a485b9 100755 --- a/arm/batch/account.go +++ b/arm/batch/account.go @@ -54,7 +54,9 @@ func NewAccountClientWithBaseURI(baseURI string, subscriptionID string) AccountC // service in the region in which the account is created. For example: // http://accountname.region.batch.azure.com/. parameters is additional // parameters for account creation. -func (client AccountClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client AccountClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (<-chan Account, <-chan error) { + resultChan := make(chan Account, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, @@ -72,26 +74,40 @@ func (client AccountClient) Create(resourceGroupName string, accountName string, {Target: "parameters.AccountBaseProperties.KeyVaultReference.URL", Name: validation.Null, Rule: true, Chain: nil}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "batch.AccountClient", "Create") - } - - req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "batch.AccountClient", "Create", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "batch.AccountClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Account + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -127,13 +143,14 @@ func (client AccountClient) CreateSender(req *http.Request) (*http.Response, err // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client AccountClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client AccountClient) CreateResponder(resp *http.Response) (result Account, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -144,7 +161,9 @@ func (client AccountClient) CreateResponder(resp *http.Response) (result autores // // resourceGroupName is the name of the resource group that contains the Batch // account to be deleted. accountName is the name of the account to be deleted. -func (client AccountClient) Delete(resourceGroupName string, accountName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client AccountClient) Delete(resourceGroupName string, accountName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}, @@ -152,26 +171,40 @@ func (client AccountClient) Delete(resourceGroupName string, accountName string, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, {Target: "accountName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "batch.AccountClient", "Delete") - } - - req, err := client.DeletePreparer(resourceGroupName, accountName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "batch.AccountClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, accountName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -232,13 +265,15 @@ func (client AccountClient) Get(resourceGroupName string, accountName string) (r req, err := client.GetPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -310,13 +345,15 @@ func (client AccountClient) GetKeys(resourceGroupName string, accountName string req, err := client.GetKeysPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "GetKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "GetKeys", nil, "Failure preparing request") + return } resp, err := client.GetKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "GetKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "GetKeys", resp, "Failure sending request") + return } result, err = client.GetKeysResponder(resp) @@ -372,13 +409,15 @@ func (client AccountClient) GetKeysResponder(resp *http.Response) (result Accoun func (client AccountClient) List() (result AccountListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -465,13 +504,15 @@ func (client AccountClient) ListByResourceGroup(resourceGroupName string) (resul req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -563,13 +604,15 @@ func (client AccountClient) RegenerateKey(resourceGroupName string, accountName req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "RegenerateKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "RegenerateKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "RegenerateKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "RegenerateKey", resp, "Failure sending request") + return } result, err = client.RegenerateKeyResponder(resp) @@ -640,13 +683,15 @@ func (client AccountClient) SynchronizeAutoStorageKeys(resourceGroupName string, req, err := client.SynchronizeAutoStorageKeysPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys", nil, "Failure preparing request") + return } resp, err := client.SynchronizeAutoStorageKeysSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "SynchronizeAutoStorageKeys", resp, "Failure sending request") + return } result, err = client.SynchronizeAutoStorageKeysResponder(resp) @@ -714,13 +759,15 @@ func (client AccountClient) Update(resourceGroupName string, accountName string, req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.AccountClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.AccountClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/batch/application.go b/arm/batch/application.go index 32f8cc72a7ea..1701b29120e0 100755 --- a/arm/batch/application.go +++ b/arm/batch/application.go @@ -60,13 +60,15 @@ func (client ApplicationClient) Create(resourceGroupName string, accountName str req, err := client.CreatePreparer(resourceGroupName, accountName, applicationID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -141,13 +143,15 @@ func (client ApplicationClient) Delete(resourceGroupName string, accountName str req, err := client.DeletePreparer(resourceGroupName, accountName, applicationID) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -216,13 +220,15 @@ func (client ApplicationClient) Get(resourceGroupName string, accountName string req, err := client.GetPreparer(resourceGroupName, accountName, applicationID) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -292,13 +298,15 @@ func (client ApplicationClient) List(resourceGroupName string, accountName strin req, err := client.ListPreparer(resourceGroupName, accountName, maxresults) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -394,13 +402,15 @@ func (client ApplicationClient) Update(resourceGroupName string, accountName str req, err := client.UpdatePreparer(resourceGroupName, accountName, applicationID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "batch.ApplicationClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/batch/applicationpackage.go b/arm/batch/applicationpackage.go index 3ce3f2ebdcc8..0fe441880aa9 100755 --- a/arm/batch/applicationpackage.go +++ b/arm/batch/applicationpackage.go @@ -64,13 +64,15 @@ func (client ApplicationPackageClient) Activate(resourceGroupName string, accoun req, err := client.ActivatePreparer(resourceGroupName, accountName, applicationID, version, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Activate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Activate", nil, "Failure preparing request") + return } resp, err := client.ActivateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Activate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Activate", resp, "Failure sending request") + return } result, err = client.ActivateResponder(resp) @@ -142,13 +144,15 @@ func (client ApplicationPackageClient) Create(resourceGroupName string, accountN req, err := client.CreatePreparer(resourceGroupName, accountName, applicationID, version) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -219,13 +223,15 @@ func (client ApplicationPackageClient) Delete(resourceGroupName string, accountN req, err := client.DeletePreparer(resourceGroupName, accountName, applicationID, version) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -295,13 +301,15 @@ func (client ApplicationPackageClient) Get(resourceGroupName string, accountName req, err := client.GetPreparer(resourceGroupName, accountName, applicationID, version) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.ApplicationPackageClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) diff --git a/arm/batch/location.go b/arm/batch/location.go index 1d815902282e..7ee2e0c721d0 100755 --- a/arm/batch/location.go +++ b/arm/batch/location.go @@ -47,13 +47,15 @@ func NewLocationClientWithBaseURI(baseURI string, subscriptionID string) Locatio func (client LocationClient) GetQuotas(locationName string) (result LocationQuota, err error) { req, err := client.GetQuotasPreparer(locationName) if err != nil { - return result, autorest.NewErrorWithError(err, "batch.LocationClient", "GetQuotas", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "batch.LocationClient", "GetQuotas", nil, "Failure preparing request") + return } resp, err := client.GetQuotasSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "batch.LocationClient", "GetQuotas", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "batch.LocationClient", "GetQuotas", resp, "Failure sending request") + return } result, err = client.GetQuotasResponder(resp) diff --git a/arm/batch/version.go b/arm/batch/version.go index a7f35295073c..cf5ecaabb30d 100755 --- a/arm/batch/version.go +++ b/arm/batch/version.go @@ -20,10 +20,10 @@ package batch // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-batch/2017-01-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-batch/2017-01-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/billing/client.go b/arm/billing/client.go index 4a725eed2606..9b65a1cacfe4 100644 --- a/arm/billing/client.go +++ b/arm/billing/client.go @@ -1,5 +1,5 @@ // Package billing implements the Azure ARM Billing service API version -// 2017-02-27-preview. +// 2017-04-24-preview. // // Billing client provides access to billing resources for Azure Web-Direct // subscriptions. Other subscription types which were not purchased directly @@ -29,9 +29,6 @@ import ( ) const ( - // APIVersion is the version of the Billing - APIVersion = "2017-02-27-preview" - // DefaultBaseURI is the default URI used for the service Billing DefaultBaseURI = "https://management.azure.com" ) @@ -40,7 +37,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -54,7 +50,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/arm/billing/invoices.go b/arm/billing/invoices.go index 5973d8468cb4..25c6fa2d7e3c 100644 --- a/arm/billing/invoices.go +++ b/arm/billing/invoices.go @@ -51,13 +51,15 @@ func NewInvoicesClientWithBaseURI(baseURI string, subscriptionID string) Invoice func (client InvoicesClient) Get(invoiceName string) (result Invoice, err error) { req, err := client.GetPreparer(invoiceName) if err != nil { - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -75,8 +77,9 @@ func (client InvoicesClient) GetPreparer(invoiceName string) (*http.Request, err "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-04-24-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -111,13 +114,15 @@ func (client InvoicesClient) GetResponder(resp *http.Response) (result Invoice, func (client InvoicesClient) GetLatest() (result Invoice, err error) { req, err := client.GetLatestPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetLatest", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetLatest", nil, "Failure preparing request") + return } resp, err := client.GetLatestSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetLatest", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetLatest", resp, "Failure sending request") + return } result, err = client.GetLatestResponder(resp) @@ -134,8 +139,9 @@ func (client InvoicesClient) GetLatestPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-04-24-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -168,14 +174,14 @@ func (client InvoicesClient) GetLatestResponder(resp *http.Response) (result Inv // List lists the available invoices for a subscription in reverse // chronological order beginning with the most recent invoice. In preview, // invoices are available via this API only for invoice periods which end -// December 1, 2016 or later +// December 1, 2016 or later. // // expand is may be used to expand the downloadUrl property within a list of // invoices. This enables download links to be generated for multiple invoices // at once. By default, downloadURLs are not included when listing invoices. // filter is may be used to filter invoices by invoicePeriodEndDate. The filter // supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently -// support 'ne', 'or', or 'not' skiptoken is skiptoken is only used if a +// support 'ne', 'or', or 'not'. skiptoken is skiptoken is only used if a // previous operation returned a partial result. If a previous response // contains a nextLink element, the value of the nextLink element will include // a skiptoken parameter that specifies a starting point to use for subsequent @@ -193,13 +199,15 @@ func (client InvoicesClient) List(expand string, filter string, skiptoken string req, err := client.ListPreparer(expand, filter, skiptoken, top) if err != nil { - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -216,8 +224,9 @@ func (client InvoicesClient) ListPreparer(expand string, filter string, skiptoke "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-04-24-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(expand) > 0 { queryParameters["$expand"] = autorest.Encode("query", expand) diff --git a/arm/billing/models.go b/arm/billing/models.go index 95c8af21904d..03c32d20c3dc 100644 --- a/arm/billing/models.go +++ b/arm/billing/models.go @@ -57,13 +57,14 @@ type Invoice struct { // InvoiceProperties is the properties of the invoice. type InvoiceProperties struct { + DownloadURL *DownloadURL `json:"downloadUrl,omitempty"` InvoicePeriodStartDate *date.Date `json:"invoicePeriodStartDate,omitempty"` InvoicePeriodEndDate *date.Date `json:"invoicePeriodEndDate,omitempty"` - DownloadURL *DownloadURL `json:"downloadUrl,omitempty"` + BillingPeriodIds *[]string `json:"billingPeriodIds,omitempty"` } -// InvoicesListResult is result of the request to list invoices. It contains a -// list of available invoices in reverse chronological order. +// InvoicesListResult is result of listing invoices. It contains a list of +// available invoices in reverse chronological order. type InvoicesListResult struct { autorest.Response `json:"-"` Value *[]Invoice `json:"value,omitempty"` @@ -82,7 +83,7 @@ func (client InvoicesListResult) InvoicesListResultPreparer() (*http.Request, er autorest.WithBaseURL(to.String(client.NextLink))) } -// Operation is a Billing REST API operation +// Operation is a Billing REST API operation. type Operation struct { Name *string `json:"name,omitempty"` Display *OperationDisplay `json:"display,omitempty"` @@ -95,8 +96,8 @@ type OperationDisplay struct { Operation *string `json:"operation,omitempty"` } -// OperationListResult is result of the request to list billing operations. It -// contains a list of operations and a URL link to get the next set of results. +// OperationListResult is result listing billing operations. It contains a list +// of operations and a URL link to get the next set of results. type OperationListResult struct { autorest.Response `json:"-"` Value *[]Operation `json:"value,omitempty"` @@ -115,6 +116,42 @@ func (client OperationListResult) OperationListResultPreparer() (*http.Request, autorest.WithBaseURL(to.String(client.NextLink))) } +// Period is a billing period resource. +type Period struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *PeriodProperties `json:"properties,omitempty"` +} + +// PeriodProperties is the properties of the billing period. +type PeriodProperties struct { + BillingPeriodStartDate *date.Date `json:"billingPeriodStartDate,omitempty"` + BillingPeriodEndDate *date.Date `json:"billingPeriodEndDate,omitempty"` + InvoiceIds *[]string `json:"invoiceIds,omitempty"` +} + +// PeriodsListResult is result of listing billing periods. It contains a list +// of available billing periods in reverse chronological order. +type PeriodsListResult struct { + autorest.Response `json:"-"` + Value *[]Period `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// PeriodsListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client PeriodsListResult) PeriodsListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + // Resource is the Resource model definition. type Resource struct { ID *string `json:"id,omitempty"` diff --git a/arm/billing/operations.go b/arm/billing/operations.go index b2a19b840fbe..32baa3a54144 100644 --- a/arm/billing/operations.go +++ b/arm/billing/operations.go @@ -47,13 +47,15 @@ func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) Opera func (client OperationsClient) List() (result OperationListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "billing.OperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "billing.OperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -66,8 +68,9 @@ func (client OperationsClient) List() (result OperationListResult, err error) { // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2017-04-24-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/billing/periods.go b/arm/billing/periods.go new file mode 100644 index 000000000000..3178c9828fec --- /dev/null +++ b/arm/billing/periods.go @@ -0,0 +1,221 @@ +package billing + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// PeriodsClient is the billing client provides access to billing resources for +// Azure Web-Direct subscriptions. Other subscription types which were not +// purchased directly through the Azure web portal are not supported through +// this preview API. +type PeriodsClient struct { + ManagementClient +} + +// NewPeriodsClient creates an instance of the PeriodsClient client. +func NewPeriodsClient(subscriptionID string) PeriodsClient { + return NewPeriodsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPeriodsClientWithBaseURI creates an instance of the PeriodsClient client. +func NewPeriodsClientWithBaseURI(baseURI string, subscriptionID string) PeriodsClient { + return PeriodsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a named billing period. +// +// billingPeriodName is the name of a BillingPeriod resource. +func (client PeriodsClient) Get(billingPeriodName string) (result Period, err error) { + req, err := client.GetPreparer(billingPeriodName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PeriodsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PeriodsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PeriodsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PeriodsClient) GetPreparer(billingPeriodName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingPeriodName": autorest.Encode("path", billingPeriodName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-24-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PeriodsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PeriodsClient) GetResponder(resp *http.Response) (result Period, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the available billing periods for a subscription in reverse +// chronological order. +// +// filter is may be used to filter billing periods by billingPeriodEndDate. The +// filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not +// currently support 'ne', 'or', or 'not'. skiptoken is skiptoken is only used +// if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include +// a skiptoken parameter that specifies a starting point to use for subsequent +// calls. top is may be used to limit the number of results to the most recent +// N billing periods. +func (client PeriodsClient) List(filter string, skiptoken string, top *int32) (result PeriodsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: 100, Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "billing.PeriodsClient", "List") + } + + req, err := client.ListPreparer(filter, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PeriodsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PeriodsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PeriodsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client PeriodsClient) ListPreparer(filter string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-24-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PeriodsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PeriodsClient) ListResponder(resp *http.Response) (result PeriodsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client PeriodsClient) ListNextResults(lastResults PeriodsListResult) (result PeriodsListResult, err error) { + req, err := lastResults.PeriodsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PeriodsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PeriodsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PeriodsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/billing/version.go b/arm/billing/version.go index bbad280c0c39..b092e9772a97 100644 --- a/arm/billing/version.go +++ b/arm/billing/version.go @@ -18,43 +18,12 @@ package billing // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "billing", "2017-02-27-preview") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.0-beta arm-billing/2017-04-24-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.0-beta" } diff --git a/arm/cdn/client.go b/arm/cdn/client.go index ddcd786874bd..bd5ca9d8b583 100755 --- a/arm/cdn/client.go +++ b/arm/cdn/client.go @@ -70,13 +70,15 @@ func (client ManagementClient) CheckNameAvailability(checkNameAvailabilityInput req, err := client.CheckNameAvailabilityPreparer(checkNameAvailabilityInput) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "CheckNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckNameAvailabilityResponder(resp) @@ -127,13 +129,15 @@ func (client ManagementClient) CheckNameAvailabilityResponder(resp *http.Respons func (client ManagementClient) ListOperations() (result OperationListResult, err error) { req, err := client.ListOperationsPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", nil, "Failure preparing request") + return } resp, err := client.ListOperationsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListOperations", resp, "Failure sending request") + return } result, err = client.ListOperationsResponder(resp) @@ -207,13 +211,15 @@ func (client ManagementClient) ListOperationsNextResults(lastResults OperationLi func (client ManagementClient) ListResourceUsage() (result ResourceUsageListResult, err error) { req, err := client.ListResourceUsagePreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", nil, "Failure preparing request") + return } resp, err := client.ListResourceUsageSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ManagementClient", "ListResourceUsage", resp, "Failure sending request") + return } result, err = client.ListResourceUsageResponder(resp) diff --git a/arm/cdn/customdomains.go b/arm/cdn/customdomains.go index db9b8d3c15db..6889272175a6 100755 --- a/arm/cdn/customdomains.go +++ b/arm/cdn/customdomains.go @@ -55,7 +55,9 @@ func NewCustomDomainsClientWithBaseURI(baseURI string, subscriptionID string) Cu // which is unique globally. customDomainName is name of the custom domain // within an endpoint. customDomainProperties is properties required to create // a new custom domain. -func (client CustomDomainsClient) Create(resourceGroupName string, profileName string, endpointName string, customDomainName string, customDomainProperties CustomDomainParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client CustomDomainsClient) Create(resourceGroupName string, profileName string, endpointName string, customDomainName string, customDomainProperties CustomDomainParameters, cancel <-chan struct{}) (<-chan CustomDomain, <-chan error) { + resultChan := make(chan CustomDomain, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -64,26 +66,40 @@ func (client CustomDomainsClient) Create(resourceGroupName string, profileName s {TargetValue: customDomainProperties, Constraints: []validation.Constraint{{Target: "customDomainProperties.CustomDomainPropertiesParameters", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "customDomainProperties.CustomDomainPropertiesParameters.HostName", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Create") - } - - req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, customDomainName, customDomainProperties, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result CustomDomain + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, customDomainName, customDomainProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -121,13 +137,14 @@ func (client CustomDomainsClient) CreateSender(req *http.Request) (*http.Respons // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client CustomDomainsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client CustomDomainsClient) CreateResponder(resp *http.Response) (result CustomDomain, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -141,32 +158,48 @@ func (client CustomDomainsClient) CreateResponder(resp *http.Response) (result a // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. customDomainName is name of the custom domain // within an endpoint. -func (client CustomDomainsClient) Delete(resourceGroupName string, profileName string, endpointName string, customDomainName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client CustomDomainsClient) Delete(resourceGroupName string, profileName string, endpointName string, customDomainName string, cancel <-chan struct{}) (<-chan CustomDomain, <-chan error) { + resultChan := make(chan CustomDomain, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Delete") - } - - req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, customDomainName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.CustomDomainsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result CustomDomain + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, customDomainName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -202,13 +235,14 @@ func (client CustomDomainsClient) DeleteSender(req *http.Request) (*http.Respons // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client CustomDomainsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client CustomDomainsClient) DeleteResponder(resp *http.Response) (result CustomDomain, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -230,13 +264,15 @@ func (client CustomDomainsClient) DisableCustomHTTPS(resourceGroupName string, p req, err := client.DisableCustomHTTPSPreparer(resourceGroupName, profileName, endpointName, customDomainName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS", nil, "Failure preparing request") + return } resp, err := client.DisableCustomHTTPSSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "DisableCustomHTTPS", resp, "Failure sending request") + return } result, err = client.DisableCustomHTTPSResponder(resp) @@ -307,13 +343,15 @@ func (client CustomDomainsClient) EnableCustomHTTPS(resourceGroupName string, pr req, err := client.EnableCustomHTTPSPreparer(resourceGroupName, profileName, endpointName, customDomainName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS", nil, "Failure preparing request") + return } resp, err := client.EnableCustomHTTPSSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "EnableCustomHTTPS", resp, "Failure sending request") + return } result, err = client.EnableCustomHTTPSResponder(resp) @@ -384,13 +422,15 @@ func (client CustomDomainsClient) Get(resourceGroupName string, profileName stri req, err := client.GetPreparer(resourceGroupName, profileName, endpointName, customDomainName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -460,13 +500,15 @@ func (client CustomDomainsClient) ListByEndpoint(resourceGroupName string, profi req, err := client.ListByEndpointPreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", nil, "Failure preparing request") + return } resp, err := client.ListByEndpointSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsClient", "ListByEndpoint", resp, "Failure sending request") + return } result, err = client.ListByEndpointResponder(resp) diff --git a/arm/cdn/edgenodes.go b/arm/cdn/edgenodes.go index 190b24789a32..a68b5c1896e7 100755 --- a/arm/cdn/edgenodes.go +++ b/arm/cdn/edgenodes.go @@ -46,13 +46,15 @@ func NewEdgeNodesClientWithBaseURI(baseURI string, subscriptionID string) EdgeNo func (client EdgeNodesClient) List() (result EdgenodeResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EdgeNodesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/cdn/endpoints.go b/arm/cdn/endpoints.go index 38cf134de0ff..dcc411e0528e 100755 --- a/arm/cdn/endpoints.go +++ b/arm/cdn/endpoints.go @@ -53,7 +53,9 @@ func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) Endpoi // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. endpoint is endpoint properties -func (client EndpointsClient) Create(resourceGroupName string, profileName string, endpointName string, endpoint Endpoint, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Create(resourceGroupName string, profileName string, endpointName string, endpoint Endpoint, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -62,26 +64,40 @@ func (client EndpointsClient) Create(resourceGroupName string, profileName strin {TargetValue: endpoint, Constraints: []validation.Constraint{{Target: "endpoint.EndpointProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "endpoint.EndpointProperties.Origins", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Create") - } - - req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, endpoint, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, profileName, endpointName, endpoint, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -118,13 +134,14 @@ func (client EndpointsClient) CreateSender(req *http.Request) (*http.Response, e // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client EndpointsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) CreateResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -138,32 +155,48 @@ func (client EndpointsClient) CreateResponder(resp *http.Response) (result autor // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. -func (client EndpointsClient) Delete(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Delete(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Delete") - } - - req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, profileName, endpointName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -226,13 +259,15 @@ func (client EndpointsClient) Get(resourceGroupName string, profileName string, req, err := client.GetPreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -300,13 +335,15 @@ func (client EndpointsClient) ListByProfile(resourceGroupName string, profileNam req, err := client.ListByProfilePreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", nil, "Failure preparing request") + return } resp, err := client.ListByProfileSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListByProfile", resp, "Failure sending request") + return } result, err = client.ListByProfileResponder(resp) @@ -399,13 +436,15 @@ func (client EndpointsClient) ListResourceUsage(resourceGroupName string, profil req, err := client.ListResourceUsagePreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", nil, "Failure preparing request") + return } resp, err := client.ListResourceUsageSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ListResourceUsage", resp, "Failure sending request") + return } result, err = client.ListResourceUsageResponder(resp) @@ -492,7 +531,9 @@ func (client EndpointsClient) ListResourceUsageNextResults(lastResults ResourceU // which is unique globally. contentFilePaths is the path to the content to be // loaded. Path should be a full URL, e.g. ‘/pictires/city.png' which loads a // single file -func (client EndpointsClient) LoadContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) LoadContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths LoadParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -500,26 +541,40 @@ func (client EndpointsClient) LoadContent(resourceGroupName string, profileName {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: contentFilePaths, Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "LoadContent") - } - - req, err := client.LoadContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", nil, "Failure preparing request") - } - - resp, err := client.LoadContentSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure sending request") - } - - result, err = client.LoadContentResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "LoadContent") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.LoadContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", nil, "Failure preparing request") + return + } + + resp, err := client.LoadContentSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure sending request") + return + } + + result, err = client.LoadContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "LoadContent", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // LoadContentPreparer prepares the LoadContent request. @@ -578,7 +633,9 @@ func (client EndpointsClient) LoadContentResponder(resp *http.Response) (result // purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a // single file, or a directory with a wildcard, e.g. '/pictures/*' which // removes all folders and files in the directory. -func (client EndpointsClient) PurgeContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) PurgeContent(resourceGroupName string, profileName string, endpointName string, contentFilePaths PurgeParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -586,26 +643,40 @@ func (client EndpointsClient) PurgeContent(resourceGroupName string, profileName {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: contentFilePaths, Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "PurgeContent") - } - - req, err := client.PurgeContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", nil, "Failure preparing request") - } - - resp, err := client.PurgeContentSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure sending request") - } - - result, err = client.PurgeContentResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "PurgeContent") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PurgeContentPreparer(resourceGroupName, profileName, endpointName, contentFilePaths, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", nil, "Failure preparing request") + return + } + + resp, err := client.PurgeContentSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure sending request") + return + } + + result, err = client.PurgeContentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "PurgeContent", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PurgeContentPreparer prepares the PurgeContent request. @@ -661,32 +732,48 @@ func (client EndpointsClient) PurgeContentResponder(resp *http.Response) (result // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. -func (client EndpointsClient) Start(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Start(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Start") - } - - req, err := client.StartPreparer(resourceGroupName, profileName, endpointName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", nil, "Failure preparing request") - } - - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure sending request") - } - - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Start") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, profileName, endpointName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. @@ -721,13 +808,14 @@ func (client EndpointsClient) StartSender(req *http.Request) (*http.Response, er // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client EndpointsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) StartResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -740,32 +828,48 @@ func (client EndpointsClient) StartResponder(resp *http.Response) (result autore // subscription. profileName is name of the CDN profile which is unique within // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. -func (client EndpointsClient) Stop(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Stop(resourceGroupName string, profileName string, endpointName string, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Stop") - } - - req, err := client.StopPreparer(resourceGroupName, profileName, endpointName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", nil, "Failure preparing request") - } - - resp, err := client.StopSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure sending request") - } - - result, err = client.StopResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Stop") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StopPreparer(resourceGroupName, profileName, endpointName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Stop", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StopPreparer prepares the Stop request. @@ -800,13 +904,14 @@ func (client EndpointsClient) StopSender(req *http.Request) (*http.Response, err // StopResponder handles the response to the Stop request. The method always // closes the http.Response Body. -func (client EndpointsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) StopResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -823,32 +928,48 @@ func (client EndpointsClient) StopResponder(resp *http.Response) (result autores // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. endpointUpdateProperties is endpoint update // properties -func (client EndpointsClient) Update(resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client EndpointsClient) Update(resourceGroupName string, profileName string, endpointName string, endpointUpdateProperties EndpointUpdateParameters, cancel <-chan struct{}) (<-chan Endpoint, <-chan error) { + resultChan := make(chan Endpoint, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Update") - } - - req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, endpointUpdateProperties, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", nil, "Failure preparing request") - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure sending request") - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.EndpointsClient", "Update") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Endpoint + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, endpointUpdateProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -885,13 +1006,14 @@ func (client EndpointsClient) UpdateSender(req *http.Request) (*http.Response, e // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client EndpointsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client EndpointsClient) UpdateResponder(resp *http.Response) (result Endpoint, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -916,13 +1038,15 @@ func (client EndpointsClient) ValidateCustomDomain(resourceGroupName string, pro req, err := client.ValidateCustomDomainPreparer(resourceGroupName, profileName, endpointName, customDomainProperties) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", nil, "Failure preparing request") + return } resp, err := client.ValidateCustomDomainSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.EndpointsClient", "ValidateCustomDomain", resp, "Failure sending request") + return } result, err = client.ValidateCustomDomainResponder(resp) diff --git a/arm/cdn/origins.go b/arm/cdn/origins.go index 5a9ba17e1d41..f9fa1ff5c058 100755 --- a/arm/cdn/origins.go +++ b/arm/cdn/origins.go @@ -60,13 +60,15 @@ func (client OriginsClient) Get(resourceGroupName string, profileName string, en req, err := client.GetPreparer(resourceGroupName, profileName, endpointName, originName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -136,13 +138,15 @@ func (client OriginsClient) ListByEndpoint(resourceGroupName string, profileName req, err := client.ListByEndpointPreparer(resourceGroupName, profileName, endpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", nil, "Failure preparing request") + return } resp, err := client.ListByEndpointSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "ListByEndpoint", resp, "Failure sending request") + return } result, err = client.ListByEndpointResponder(resp) @@ -228,32 +232,48 @@ func (client OriginsClient) ListByEndpointNextResults(lastResults OriginListResu // the resource group. endpointName is name of the endpoint under the profile // which is unique globally. originName is name of the origin which is unique // within the endpoint. originUpdateProperties is origin properties -func (client OriginsClient) Update(resourceGroupName string, profileName string, endpointName string, originName string, originUpdateProperties OriginUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client OriginsClient) Update(resourceGroupName string, profileName string, endpointName string, originName string, originUpdateProperties OriginUpdateParameters, cancel <-chan struct{}) (<-chan Origin, <-chan error) { + resultChan := make(chan Origin, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.OriginsClient", "Update") - } - - req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, originName, originUpdateProperties, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", nil, "Failure preparing request") - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure sending request") - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure responding to request") + errChan <- validation.NewErrorWithValidationError(err, "cdn.OriginsClient", "Update") + close(errChan) + close(resultChan) + return resultChan, errChan } - return + go func() { + var err error + var result Origin + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointName, originName, originUpdateProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.OriginsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -291,12 +311,13 @@ func (client OriginsClient) UpdateSender(req *http.Request) (*http.Response, err // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client OriginsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client OriginsClient) UpdateResponder(resp *http.Response) (result Origin, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/cdn/profiles.go b/arm/cdn/profiles.go index c265da9b60aa..c166a1b73007 100755 --- a/arm/cdn/profiles.go +++ b/arm/cdn/profiles.go @@ -52,7 +52,9 @@ func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) Profile // subscription. profileName is name of the CDN profile which is unique within // the resource group. profile is profile properties needed to create a new // profile. -func (client ProfilesClient) Create(resourceGroupName string, profileName string, profile Profile, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ProfilesClient) Create(resourceGroupName string, profileName string, profile Profile, cancel <-chan struct{}) (<-chan Profile, <-chan error) { + resultChan := make(chan Profile, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -60,26 +62,40 @@ func (client ProfilesClient) Create(resourceGroupName string, profileName string {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, {TargetValue: profile, Constraints: []validation.Constraint{{Target: "profile.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Create") - } - - req, err := client.CreatePreparer(resourceGroupName, profileName, profile, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Profile + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, profileName, profile, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -115,13 +131,14 @@ func (client ProfilesClient) CreateSender(req *http.Request) (*http.Response, er // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client ProfilesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProfilesClient) CreateResponder(resp *http.Response) (result Profile, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -135,32 +152,48 @@ func (client ProfilesClient) CreateResponder(resp *http.Response) (result autore // resourceGroupName is name of the Resource group within the Azure // subscription. profileName is name of the CDN profile which is unique within // the resource group. -func (client ProfilesClient) Delete(resourceGroupName string, profileName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ProfilesClient) Delete(resourceGroupName string, profileName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Delete") - } - - req, err := client.DeletePreparer(resourceGroupName, profileName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, profileName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -225,13 +258,15 @@ func (client ProfilesClient) GenerateSsoURI(resourceGroupName string, profileNam req, err := client.GenerateSsoURIPreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", nil, "Failure preparing request") + return } resp, err := client.GenerateSsoURISender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "GenerateSsoURI", resp, "Failure sending request") + return } result, err = client.GenerateSsoURIResponder(resp) @@ -299,13 +334,15 @@ func (client ProfilesClient) Get(resourceGroupName string, profileName string) ( req, err := client.GetPreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -360,13 +397,15 @@ func (client ProfilesClient) GetResponder(resp *http.Response) (result Profile, func (client ProfilesClient) List() (result ProfileListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -454,13 +493,15 @@ func (client ProfilesClient) ListByResourceGroup(resourceGroupName string) (resu req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -551,13 +592,15 @@ func (client ProfilesClient) ListResourceUsage(resourceGroupName string, profile req, err := client.ListResourceUsagePreparer(resourceGroupName, profileName) if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", nil, "Failure preparing request") + return } resp, err := client.ListResourceUsageSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "ListResourceUsage", resp, "Failure sending request") + return } result, err = client.ListResourceUsageResponder(resp) @@ -642,32 +685,48 @@ func (client ProfilesClient) ListResourceUsageNextResults(lastResults ResourceUs // subscription. profileName is name of the CDN profile which is unique within // the resource group. profileUpdateParameters is profile properties needed to // update an existing profile. -func (client ProfilesClient) Update(resourceGroupName string, profileName string, profileUpdateParameters ProfileUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ProfilesClient) Update(resourceGroupName string, profileName string, profileUpdateParameters ProfileUpdateParameters, cancel <-chan struct{}) (<-chan Profile, <-chan error) { + resultChan := make(chan Profile, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Update") - } - - req, err := client.UpdatePreparer(resourceGroupName, profileName, profileUpdateParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", nil, "Failure preparing request") - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure sending request") - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "cdn.ProfilesClient", "Update") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Profile + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, profileName, profileUpdateParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -703,12 +762,13 @@ func (client ProfilesClient) UpdateSender(req *http.Request) (*http.Response, er // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client ProfilesClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProfilesClient) UpdateResponder(resp *http.Response) (result Profile, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/cdn/version.go b/arm/cdn/version.go index 0299150ffc96..4be701b8e98e 100755 --- a/arm/cdn/version.go +++ b/arm/cdn/version.go @@ -20,10 +20,10 @@ package cdn // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-cdn/2016-10-02" + return "Azure-SDK-For-Go/v10.0.0-beta arm-cdn/2016-10-02" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/cognitiveservices/accounts.go b/arm/cognitiveservices/accounts.go index f423b9c7b82f..76cb1d4f96a8 100755 --- a/arm/cognitiveservices/accounts.go +++ b/arm/cognitiveservices/accounts.go @@ -66,13 +66,15 @@ func (client AccountsClient) Create(resourceGroupName string, accountName string req, err := client.CreatePreparer(resourceGroupName, accountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -143,13 +145,15 @@ func (client AccountsClient) Delete(resourceGroupName string, accountName string req, err := client.DeletePreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -218,13 +222,15 @@ func (client AccountsClient) GetProperties(resourceGroupName string, accountName req, err := client.GetPropertiesPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", nil, "Failure preparing request") + return } resp, err := client.GetPropertiesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "GetProperties", resp, "Failure sending request") + return } result, err = client.GetPropertiesResponder(resp) @@ -280,13 +286,15 @@ func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result func (client AccountsClient) List() (result AccountListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -343,13 +351,15 @@ func (client AccountsClient) ListResponder(resp *http.Response) (result AccountL func (client AccountsClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -418,13 +428,15 @@ func (client AccountsClient) ListKeys(resourceGroupName string, accountName stri req, err := client.ListKeysPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -493,13 +505,15 @@ func (client AccountsClient) ListSkus(resourceGroupName string, accountName stri req, err := client.ListSkusPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", nil, "Failure preparing request") + return } resp, err := client.ListSkusSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "ListSkus", resp, "Failure sending request") + return } result, err = client.ListSkusResponder(resp) @@ -569,13 +583,15 @@ func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, body) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "RegenerateKey", resp, "Failure sending request") + return } result, err = client.RegenerateKeyResponder(resp) @@ -646,13 +662,15 @@ func (client AccountsClient) Update(resourceGroupName string, accountName string req, err := client.UpdatePreparer(resourceGroupName, accountName, body) if err != nil { - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "cognitiveservices.AccountsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/cognitiveservices/version.go b/arm/cognitiveservices/version.go index b978d76ce9e0..26101f7d828e 100755 --- a/arm/cognitiveservices/version.go +++ b/arm/cognitiveservices/version.go @@ -20,10 +20,10 @@ package cognitiveservices // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-cognitiveservices/2016-02-01-preview" + return "Azure-SDK-For-Go/v10.0.0-beta arm-cognitiveservices/2016-02-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/commerce/client.go b/arm/commerce/client.go index e1d980e9f9f4..289d50cfedb7 100644 --- a/arm/commerce/client.go +++ b/arm/commerce/client.go @@ -1,6 +1,7 @@ // Package commerce implements the Azure ARM Commerce service API version // 2015-06-01-preview. // +// package commerce // Copyright (c) Microsoft and contributors. All rights reserved. @@ -17,7 +18,7 @@ package commerce // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -26,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Commerce - APIVersion = "2015-06-01-preview" - // DefaultBaseURI is the default URI used for the service Commerce DefaultBaseURI = "https://management.azure.com" ) @@ -37,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -51,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/arm/commerce/models.go b/arm/commerce/models.go index 04a55092a24d..1497c45d80f0 100644 --- a/arm/commerce/models.go +++ b/arm/commerce/models.go @@ -14,7 +14,7 @@ package commerce // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -37,7 +37,7 @@ const ( Hourly AggregationGranularity = "Hourly" ) -// ErrorResponse is describes ehe format of Error response. +// ErrorResponse is describes the format of Error response. type ErrorResponse struct { Code *string `json:"code,omitempty"` Message *string `json:"message,omitempty"` @@ -55,29 +55,31 @@ type MeterInfo struct { MeterCategory *string `json:"MeterCategory,omitempty"` MeterSubCategory *string `json:"MeterSubCategory,omitempty"` Unit *string `json:"Unit,omitempty"` + MeterTags *[]string `json:"MeterTags,omitempty"` + MeterRegion *string `json:"MeterRegion,omitempty"` MeterRates *map[string]*float64 `json:"MeterRates,omitempty"` EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` IncludedQuantity *float64 `json:"IncludedQuantity,omitempty"` } -// MonetaryCommitment is +// MonetaryCommitment is indicates that a monetary commitment is required for +// this offer type MonetaryCommitment struct { EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` - ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` TieredDiscount *map[string]*decimal.Decimal `json:"TieredDiscount,omitempty"` + ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` } -// MonetaryCredit is +// MonetaryCredit is indicates that this is a monetary credit offer. type MonetaryCredit struct { EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` - ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` Credit *decimal.Decimal `json:"Credit,omitempty"` + ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` } // OfferTermInfo is describes the offer term. type OfferTermInfo struct { - EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` - ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` + EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` } // RateCardQueryParameters is parameters that are used in the odata $filter @@ -89,11 +91,10 @@ type RateCardQueryParameters struct { RegionInfo *string `json:"RegionInfo,omitempty"` } -// RecurringCharge is +// RecurringCharge is indicates a recurring charge is present for this offer. type RecurringCharge struct { - EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` - ExcludedMeterIds *[]uuid.UUID `json:"ExcludedMeterIds,omitempty"` - RecurringChargeProperty *int32 `json:"RecurringCharge,omitempty"` + EffectiveDate *date.Time `json:"EffectiveDate,omitempty"` + RecurringCharge *int32 `json:"RecurringCharge,omitempty"` } // ResourceRateCardInfo is price and Metadata information for resources @@ -102,8 +103,6 @@ type ResourceRateCardInfo struct { Currency *string `json:"Currency,omitempty"` Locale *string `json:"Locale,omitempty"` IsTaxIncluded *bool `json:"IsTaxIncluded,omitempty"` - MeterRegion *string `json:"MeterRegion,omitempty"` - Tags *[]string `json:"Tags,omitempty"` OfferTerms *[]OfferTermInfo `json:"OfferTerms,omitempty"` Meters *[]MeterInfo `json:"Meters,omitempty"` } diff --git a/arm/commerce/ratecard.go b/arm/commerce/ratecard.go index d9b39c213b9d..2550c64efc35 100644 --- a/arm/commerce/ratecard.go +++ b/arm/commerce/ratecard.go @@ -14,7 +14,7 @@ package commerce // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -45,26 +45,28 @@ func NewRateCardClientWithBaseURI(baseURI string, subscriptionID string) RateCar // used in a given subscription by Offer ID, Currency, Locale and Region. The // metadata associated with the billing meters, including but not limited to // service names, types, resources, units of measure, and regions, is subject -// to change at any time and without notice. If you intend to use this -// billing data in an automated fashion, please use the billing meter GUID to -// uniquely identify each billable item. If the billing meter GUID is -// scheduled to change due to a new billing model, you will be notified in -// advance of the change. +// to change at any time and without notice. If you intend to use this billing +// data in an automated fashion, please use the billing meter GUID to uniquely +// identify each billable item. If the billing meter GUID is scheduled to +// change due to a new billing model, you will be notified in advance of the +// change. // // filter is 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. +// 'OfferDurableId', 'Currency', 'Locale', 'Region' are required to be a part +// of the $filter. func (client RateCardClient) Get(filter string) (result ResourceRateCardInfo, err error) { req, err := client.GetPreparer(filter) if err != nil { - return result, autorest.NewErrorWithError(err, "commerce.RateCardClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commerce.RateCardClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commerce.RateCardClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commerce.RateCardClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -81,11 +83,10 @@ func (client RateCardClient) GetPreparer(filter string) (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-06-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/commerce/usageaggregates.go b/arm/commerce/usageaggregates.go index e39ed3a78248..4fe228405623 100644 --- a/arm/commerce/usageaggregates.go +++ b/arm/commerce/usageaggregates.go @@ -14,7 +14,7 @@ package commerce // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -45,24 +45,32 @@ func NewUsageAggregatesClientWithBaseURI(baseURI string, subscriptionID string) // List query aggregated Azure subscription consumption data for a date range. // -// reportedstartTime is the start of the time range to retrieve data for. +// reportedStartTime is the start of the time range to retrieve data for. // reportedEndTime is the end of the time range to retrieve data for. -// showDetails is when set to true (default), the aggregates are broken down -// into the instance metadata which is more granular. aggregationGranularity -// is value is either daily (default) or hourly to tell the API how to return -// the results grouped by day or hour. Possible values include: 'Daily', -// 'Hourly' continuationToken is retrieved from previous calls, this is the -// bookmark used for progress when the responses are paged. -func (client UsageAggregatesClient) List(reportedstartTime date.Time, reportedEndTime date.Time, showDetails *bool, aggregationGranularity AggregationGranularity, continuationToken string) (result UsageAggregationListResult, err error) { - req, err := client.ListPreparer(reportedstartTime, reportedEndTime, showDetails, aggregationGranularity, continuationToken) +// showDetails is `True` returns usage data in instance-level detail, `false` +// causes server-side aggregation with fewer details. For example, if you have +// 3 website instances, by default you will get 3 line items for website +// consumption. If you specify showDetails = false, the data will be aggregated +// as a single line item for website consumption within the time period (for +// the given subscriptionId, meterId, usageStartTime and usageEndTime). +// aggregationGranularity is `Daily` (default) returns the data in daily +// granularity, `Hourly` returns the data in hourly granularity. +// continuationToken is used when a continuation token string is provided in +// the response body of the previous call, enabling paging through a large +// result set. If not present, the data is retrieved from the beginning of the +// day/hour (based on the granularity) passed in. +func (client UsageAggregatesClient) List(reportedStartTime date.Time, reportedEndTime date.Time, showDetails *bool, aggregationGranularity AggregationGranularity, continuationToken string) (result UsageAggregationListResult, err error) { + req, err := client.ListPreparer(reportedStartTime, reportedEndTime, showDetails, aggregationGranularity, continuationToken) if err != nil { - return result, autorest.NewErrorWithError(err, "commerce.UsageAggregatesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commerce.UsageAggregatesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commerce.UsageAggregatesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commerce.UsageAggregatesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -74,15 +82,16 @@ func (client UsageAggregatesClient) List(reportedstartTime date.Time, reportedEn } // ListPreparer prepares the List request. -func (client UsageAggregatesClient) ListPreparer(reportedstartTime date.Time, reportedEndTime date.Time, showDetails *bool, aggregationGranularity AggregationGranularity, continuationToken string) (*http.Request, error) { +func (client UsageAggregatesClient) ListPreparer(reportedStartTime date.Time, reportedEndTime date.Time, showDetails *bool, aggregationGranularity AggregationGranularity, continuationToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2015-06-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, "reportedEndTime": autorest.Encode("query", reportedEndTime), - "reportedstartTime": autorest.Encode("query", reportedstartTime), + "reportedStartTime": autorest.Encode("query", reportedStartTime), } if showDetails != nil { queryParameters["showDetails"] = autorest.Encode("query", *showDetails) diff --git a/arm/commerce/version.go b/arm/commerce/version.go index 82138f7dd997..bf9a3bf1d3fb 100644 --- a/arm/commerce/version.go +++ b/arm/commerce/version.go @@ -18,43 +18,12 @@ package commerce // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "commerce", "2015-06-01-preview") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.0-beta arm-commerce/2015-06-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.0-beta" } diff --git a/arm/compute/availabilitysets.go b/arm/compute/availabilitysets.go index 6d308180fbd7..738c2c61ea0f 100755 --- a/arm/compute/availabilitysets.go +++ b/arm/compute/availabilitysets.go @@ -49,13 +49,15 @@ func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string) func (client AvailabilitySetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters AvailabilitySet) (result AvailabilitySet, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -115,13 +117,15 @@ func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response func (client AvailabilitySetsClient) Delete(resourceGroupName string, availabilitySetName string) (result OperationStatusResponse, err error) { req, err := client.DeletePreparer(resourceGroupName, availabilitySetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -179,13 +183,15 @@ func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (resul func (client AvailabilitySetsClient) Get(resourceGroupName string, availabilitySetName string) (result AvailabilitySet, err error) { req, err := client.GetPreparer(resourceGroupName, availabilitySetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -242,13 +248,15 @@ func (client AvailabilitySetsClient) GetResponder(resp *http.Response) (result A func (client AvailabilitySetsClient) List(resourceGroupName string) (result AvailabilitySetListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -306,13 +314,15 @@ func (client AvailabilitySetsClient) ListResponder(resp *http.Response) (result func (client AvailabilitySetsClient) ListAvailableSizes(resourceGroupName string, availabilitySetName string) (result VirtualMachineSizeListResult, err error) { req, err := client.ListAvailableSizesPreparer(resourceGroupName, availabilitySetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request") + return } resp, err := client.ListAvailableSizesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request") + return } result, err = client.ListAvailableSizesResponder(resp) diff --git a/arm/compute/images.go b/arm/compute/images.go index 09a44584b34d..64f14dd082ff 100755 --- a/arm/compute/images.go +++ b/arm/compute/images.go @@ -48,33 +48,49 @@ func NewImagesClientWithBaseURI(baseURI string, subscriptionID string) ImagesCli // resourceGroupName is the name of the resource group. imageName is the name // of the image. parameters is parameters supplied to the Create Image // operation. -func (client ImagesClient) CreateOrUpdate(resourceGroupName string, imageName string, parameters Image, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ImagesClient) CreateOrUpdate(resourceGroupName string, imageName string, parameters Image, cancel <-chan struct{}) (<-chan Image, <-chan error) { + resultChan := make(chan Image, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.ImageProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ImageProperties.StorageProfile", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ImageProperties.StorageProfile.OsDisk", Name: validation.Null, Rule: true, Chain: nil}}}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.ImagesClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, imageName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "compute.ImagesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Image + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, imageName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -110,13 +126,14 @@ func (client ImagesClient) CreateOrUpdateSender(req *http.Request) (*http.Respon // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result Image, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -126,24 +143,37 @@ func (client ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result // // resourceGroupName is the name of the resource group. imageName is the name // of the image. -func (client ImagesClient) Delete(resourceGroupName string, imageName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, imageName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure responding to request") - } - - return +func (client ImagesClient) Delete(resourceGroupName string, imageName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, imageName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -177,13 +207,14 @@ func (client ImagesClient) DeleteSender(req *http.Request) (*http.Response, erro // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client ImagesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ImagesClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -194,13 +225,15 @@ func (client ImagesClient) DeleteResponder(resp *http.Response) (result autorest func (client ImagesClient) Get(resourceGroupName string, imageName string, expand string) (result Image, err error) { req, err := client.GetPreparer(resourceGroupName, imageName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -260,13 +293,15 @@ func (client ImagesClient) GetResponder(resp *http.Response) (result Image, err func (client ImagesClient) List() (result ImageListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -345,13 +380,15 @@ func (client ImagesClient) ListNextResults(lastResults ImageListResult) (result func (client ImagesClient) ListByResourceGroup(resourceGroupName string) (result ImageListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) diff --git a/arm/compute/usage.go b/arm/compute/usage.go index b0a071d74ba2..97c53e0efd7f 100755 --- a/arm/compute/usage.go +++ b/arm/compute/usage.go @@ -54,13 +54,15 @@ func (client UsageClient) List(location string) (result ListUsagesResult, err er req, err := client.ListPreparer(location) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.UsageClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.UsageClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.UsageClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.UsageClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/compute/version.go b/arm/compute/version.go index 9c13dca55b96..f3d49ad36678 100755 --- a/arm/compute/version.go +++ b/arm/compute/version.go @@ -20,10 +20,10 @@ package compute // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-compute/2016-04-30-preview" + return "Azure-SDK-For-Go/v10.0.0-beta arm-compute/2016-04-30-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/compute/virtualmachineextensionimages.go b/arm/compute/virtualmachineextensionimages.go index 0d0b2f3eb77b..fcd122704284 100755 --- a/arm/compute/virtualmachineextensionimages.go +++ b/arm/compute/virtualmachineextensionimages.go @@ -46,13 +46,15 @@ func NewVirtualMachineExtensionImagesClientWithBaseURI(baseURI string, subscript func (client VirtualMachineExtensionImagesClient) Get(location string, publisherName string, typeParameter string, version string) (result VirtualMachineExtensionImage, err error) { req, err := client.GetPreparer(location, publisherName, typeParameter, version) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -110,13 +112,15 @@ func (client VirtualMachineExtensionImagesClient) GetResponder(resp *http.Respon func (client VirtualMachineExtensionImagesClient) ListTypes(location string, publisherName string) (result ListVirtualMachineExtensionImage, err error) { req, err := client.ListTypesPreparer(location, publisherName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request") + return } resp, err := client.ListTypesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure sending request") + return } result, err = client.ListTypesResponder(resp) @@ -173,13 +177,15 @@ func (client VirtualMachineExtensionImagesClient) ListTypesResponder(resp *http. func (client VirtualMachineExtensionImagesClient) ListVersions(location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (result ListVirtualMachineExtensionImage, err error) { req, err := client.ListVersionsPreparer(location, publisherName, typeParameter, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request") + return } resp, err := client.ListVersionsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure sending request") + return } result, err = client.ListVersionsResponder(resp) diff --git a/arm/compute/virtualmachineextensions.go b/arm/compute/virtualmachineextensions.go index f82c9ff7fdd7..2195aac2bcd9 100755 --- a/arm/compute/virtualmachineextensions.go +++ b/arm/compute/virtualmachineextensions.go @@ -51,24 +51,37 @@ func NewVirtualMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID // vmExtensionName is the name of the virtual machine extension. // extensionParameters is parameters supplied to the Create Virtual Machine // Extension operation. -func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, vmExtensionName, extensionParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return +func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (<-chan VirtualMachineExtension, <-chan error) { + resultChan := make(chan VirtualMachineExtension, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualMachineExtension + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, vmExtensionName, extensionParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -105,13 +118,14 @@ func (client VirtualMachineExtensionsClient) CreateOrUpdateSender(req *http.Requ // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineExtension, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -123,24 +137,37 @@ func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http. // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine where the extension should be deleted. vmExtensionName // is the name of the virtual machine extension. -func (client VirtualMachineExtensionsClient) Delete(resourceGroupName string, vmName string, vmExtensionName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmName, vmExtensionName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure responding to request") - } - - return +func (client VirtualMachineExtensionsClient) Delete(resourceGroupName string, vmName string, vmExtensionName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, vmName, vmExtensionName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -175,13 +202,14 @@ func (client VirtualMachineExtensionsClient) DeleteSender(req *http.Request) (*h // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -194,13 +222,15 @@ func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, vmName string, vmExtensionName string, expand string) (result VirtualMachineExtension, err error) { req, err := client.GetPreparer(resourceGroupName, vmName, vmExtensionName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) diff --git a/arm/compute/virtualmachineimages.go b/arm/compute/virtualmachineimages.go index 4ad282ef517a..6c090568f520 100755 --- a/arm/compute/virtualmachineimages.go +++ b/arm/compute/virtualmachineimages.go @@ -49,13 +49,15 @@ func NewVirtualMachineImagesClientWithBaseURI(baseURI string, subscriptionID str func (client VirtualMachineImagesClient) Get(location string, publisherName string, offer string, skus string, version string) (result VirtualMachineImage, err error) { req, err := client.GetPreparer(location, publisherName, offer, skus, version) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -118,13 +120,15 @@ func (client VirtualMachineImagesClient) GetResponder(resp *http.Response) (resu func (client VirtualMachineImagesClient) List(location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListPreparer(location, publisherName, offer, skus, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -194,13 +198,15 @@ func (client VirtualMachineImagesClient) ListResponder(resp *http.Response) (res func (client VirtualMachineImagesClient) ListOffers(location string, publisherName string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListOffersPreparer(location, publisherName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", nil, "Failure preparing request") + return } resp, err := client.ListOffersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure sending request") + return } result, err = client.ListOffersResponder(resp) @@ -258,13 +264,15 @@ func (client VirtualMachineImagesClient) ListOffersResponder(resp *http.Response func (client VirtualMachineImagesClient) ListPublishers(location string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListPublishersPreparer(location) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", nil, "Failure preparing request") + return } resp, err := client.ListPublishersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure sending request") + return } result, err = client.ListPublishersResponder(resp) @@ -322,13 +330,15 @@ func (client VirtualMachineImagesClient) ListPublishersResponder(resp *http.Resp func (client VirtualMachineImagesClient) ListSkus(location string, publisherName string, offer string) (result ListVirtualMachineImageResource, err error) { req, err := client.ListSkusPreparer(location, publisherName, offer) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", nil, "Failure preparing request") + return } resp, err := client.ListSkusSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure sending request") + return } result, err = client.ListSkusResponder(resp) diff --git a/arm/compute/virtualmachines.go b/arm/compute/virtualmachines.go index fa0d073ea671..047b5b0b5a1e 100755 --- a/arm/compute/virtualmachines.go +++ b/arm/compute/virtualmachines.go @@ -51,32 +51,48 @@ func NewVirtualMachinesClientWithBaseURI(baseURI string, subscriptionID string) // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. parameters is parameters supplied to the Capture // Virtual Machine operation. -func (client VirtualMachinesClient) Capture(resourceGroupName string, vmName string, parameters VirtualMachineCaptureParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachinesClient) Capture(resourceGroupName string, vmName string, parameters VirtualMachineCaptureParameters, cancel <-chan struct{}) (<-chan VirtualMachineCaptureResult, <-chan error) { + resultChan := make(chan VirtualMachineCaptureResult, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.VhdPrefix", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.DestinationContainerName", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.OverwriteVhds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "Capture") - } - - req, err := client.CapturePreparer(resourceGroupName, vmName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", nil, "Failure preparing request") - } - - resp, err := client.CaptureSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure sending request") - } - - result, err = client.CaptureResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "Capture") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result VirtualMachineCaptureResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CapturePreparer(resourceGroupName, vmName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", nil, "Failure preparing request") + return + } + + resp, err := client.CaptureSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure sending request") + return + } + + result, err = client.CaptureResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Capture", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CapturePreparer prepares the Capture request. @@ -112,13 +128,14 @@ func (client VirtualMachinesClient) CaptureSender(req *http.Request) (*http.Resp // CaptureResponder handles the response to the Capture request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) CaptureResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) CaptureResponder(resp *http.Response) (result VirtualMachineCaptureResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -130,24 +147,37 @@ func (client VirtualMachinesClient) CaptureResponder(resp *http.Response) (resul // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. -func (client VirtualMachinesClient) ConvertToManagedDisks(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ConvertToManagedDisksPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", nil, "Failure preparing request") - } - - resp, err := client.ConvertToManagedDisksSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure sending request") - } - - result, err = client.ConvertToManagedDisksResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure responding to request") - } - - return +func (client VirtualMachinesClient) ConvertToManagedDisks(resourceGroupName string, vmName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ConvertToManagedDisksPreparer(resourceGroupName, vmName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", nil, "Failure preparing request") + return + } + + resp, err := client.ConvertToManagedDisksSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure sending request") + return + } + + result, err = client.ConvertToManagedDisksResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ConvertToManagedDisks", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ConvertToManagedDisksPreparer prepares the ConvertToManagedDisks request. @@ -181,13 +211,14 @@ func (client VirtualMachinesClient) ConvertToManagedDisksSender(req *http.Reques // ConvertToManagedDisksResponder handles the response to the ConvertToManagedDisks request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) ConvertToManagedDisksResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) ConvertToManagedDisksResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -199,7 +230,9 @@ func (client VirtualMachinesClient) ConvertToManagedDisksResponder(resp *http.Re // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. parameters is parameters supplied to the Create Virtual // Machine operation. -func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, vmName string, parameters VirtualMachine, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, vmName string, parameters VirtualMachine, cancel <-chan struct{}) (<-chan VirtualMachine, <-chan error) { + resultChan := make(chan VirtualMachine, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.VirtualMachineProperties", Name: validation.Null, Rule: false, @@ -218,26 +251,40 @@ func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, vmN }}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachinesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result VirtualMachine + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -273,13 +320,14 @@ func (client VirtualMachinesClient) CreateOrUpdateSender(req *http.Request) (*ht // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachine, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -291,24 +339,37 @@ func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. -func (client VirtualMachinesClient) Deallocate(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeallocatePreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", nil, "Failure preparing request") - } - - resp, err := client.DeallocateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure sending request") - } - - result, err = client.DeallocateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure responding to request") - } - - return +func (client VirtualMachinesClient) Deallocate(resourceGroupName string, vmName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeallocatePreparer(resourceGroupName, vmName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", nil, "Failure preparing request") + return + } + + resp, err := client.DeallocateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure sending request") + return + } + + result, err = client.DeallocateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Deallocate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeallocatePreparer prepares the Deallocate request. @@ -342,13 +403,14 @@ func (client VirtualMachinesClient) DeallocateSender(req *http.Request) (*http.R // DeallocateResponder handles the response to the Deallocate request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) DeallocateResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -359,24 +421,37 @@ func (client VirtualMachinesClient) DeallocateResponder(resp *http.Response) (re // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. -func (client VirtualMachinesClient) Delete(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure responding to request") - } - - return +func (client VirtualMachinesClient) Delete(resourceGroupName string, vmName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, vmName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -410,13 +485,14 @@ func (client VirtualMachinesClient) DeleteSender(req *http.Request) (*http.Respo // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -427,13 +503,15 @@ func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result func (client VirtualMachinesClient) Generalize(resourceGroupName string, vmName string) (result OperationStatusResponse, err error) { req, err := client.GeneralizePreparer(resourceGroupName, vmName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", nil, "Failure preparing request") + return } resp, err := client.GeneralizeSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Generalize", resp, "Failure sending request") + return } result, err = client.GeneralizeResponder(resp) @@ -493,13 +571,15 @@ func (client VirtualMachinesClient) GeneralizeResponder(resp *http.Response) (re func (client VirtualMachinesClient) Get(resourceGroupName string, vmName string, expand InstanceViewTypes) (result VirtualMachine, err error) { req, err := client.GetPreparer(resourceGroupName, vmName, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -561,13 +641,15 @@ func (client VirtualMachinesClient) GetResponder(resp *http.Response) (result Vi func (client VirtualMachinesClient) List(resourceGroupName string) (result VirtualMachineListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -647,13 +729,15 @@ func (client VirtualMachinesClient) ListNextResults(lastResults VirtualMachineLi func (client VirtualMachinesClient) ListAll() (result VirtualMachineListResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -734,13 +818,15 @@ func (client VirtualMachinesClient) ListAllNextResults(lastResults VirtualMachin func (client VirtualMachinesClient) ListAvailableSizes(resourceGroupName string, vmName string) (result VirtualMachineSizeListResult, err error) { req, err := client.ListAvailableSizesPreparer(resourceGroupName, vmName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", nil, "Failure preparing request") + return } resp, err := client.ListAvailableSizesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", resp, "Failure sending request") + return } result, err = client.ListAvailableSizesResponder(resp) @@ -799,24 +885,37 @@ func (client VirtualMachinesClient) ListAvailableSizesResponder(resp *http.Respo // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. -func (client VirtualMachinesClient) PowerOff(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.PowerOffPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", nil, "Failure preparing request") - } - - resp, err := client.PowerOffSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure sending request") - } - - result, err = client.PowerOffResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure responding to request") - } - - return +func (client VirtualMachinesClient) PowerOff(resourceGroupName string, vmName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PowerOffPreparer(resourceGroupName, vmName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", nil, "Failure preparing request") + return + } + + resp, err := client.PowerOffSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure sending request") + return + } + + result, err = client.PowerOffResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "PowerOff", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PowerOffPreparer prepares the PowerOff request. @@ -850,13 +949,14 @@ func (client VirtualMachinesClient) PowerOffSender(req *http.Request) (*http.Res // PowerOffResponder handles the response to the PowerOff request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) PowerOffResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -867,24 +967,37 @@ func (client VirtualMachinesClient) PowerOffResponder(resp *http.Response) (resu // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. -func (client VirtualMachinesClient) Redeploy(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RedeployPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", nil, "Failure preparing request") - } - - resp, err := client.RedeploySender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure sending request") - } - - result, err = client.RedeployResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure responding to request") - } - - return +func (client VirtualMachinesClient) Redeploy(resourceGroupName string, vmName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RedeployPreparer(resourceGroupName, vmName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", nil, "Failure preparing request") + return + } + + resp, err := client.RedeploySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure sending request") + return + } + + result, err = client.RedeployResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RedeployPreparer prepares the Redeploy request. @@ -918,13 +1031,14 @@ func (client VirtualMachinesClient) RedeploySender(req *http.Request) (*http.Res // RedeployResponder handles the response to the Redeploy request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) RedeployResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) RedeployResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -935,24 +1049,37 @@ func (client VirtualMachinesClient) RedeployResponder(resp *http.Response) (resu // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. -func (client VirtualMachinesClient) Restart(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RestartPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", nil, "Failure preparing request") - } - - resp, err := client.RestartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure sending request") - } - - result, err = client.RestartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure responding to request") - } - - return +func (client VirtualMachinesClient) Restart(resourceGroupName string, vmName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RestartPreparer(resourceGroupName, vmName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", nil, "Failure preparing request") + return + } + + resp, err := client.RestartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure sending request") + return + } + + result, err = client.RestartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Restart", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RestartPreparer prepares the Restart request. @@ -986,13 +1113,14 @@ func (client VirtualMachinesClient) RestartSender(req *http.Request) (*http.Resp // RestartResponder handles the response to the Restart request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) RestartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -1003,24 +1131,37 @@ func (client VirtualMachinesClient) RestartResponder(resp *http.Response) (resul // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. -func (client VirtualMachinesClient) Start(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, vmName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", nil, "Failure preparing request") - } - - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure sending request") - } - - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure responding to request") - } - - return +func (client VirtualMachinesClient) Start(resourceGroupName string, vmName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, vmName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. @@ -1054,12 +1195,13 @@ func (client VirtualMachinesClient) StartSender(req *http.Request) (*http.Respon // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client VirtualMachinesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachinesClient) StartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/compute/virtualmachinescalesets.go b/arm/compute/virtualmachinescalesets.go index 9c53144cf900..a7d4a4127a2d 100755 --- a/arm/compute/virtualmachinescalesets.go +++ b/arm/compute/virtualmachinescalesets.go @@ -49,24 +49,37 @@ func NewVirtualMachineScaleSetsClientWithBaseURI(baseURI string, subscriptionID // // resourceGroupName is the name of the resource group. name is the name of the // VM scale set to create or update. parameters is the scale set object. -func (client VirtualMachineScaleSetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters VirtualMachineScaleSet, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters VirtualMachineScaleSet, cancel <-chan struct{}) (<-chan VirtualMachineScaleSet, <-chan error) { + resultChan := make(chan VirtualMachineScaleSet, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualMachineScaleSet + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -102,13 +115,14 @@ func (client VirtualMachineScaleSetsClient) CreateOrUpdateSender(req *http.Reque // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineScaleSet, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -122,24 +136,37 @@ func (client VirtualMachineScaleSetsClient) CreateOrUpdateResponder(resp *http.R // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. vmInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) Deallocate(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeallocatePreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", nil, "Failure preparing request") - } - - resp, err := client.DeallocateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure sending request") - } - - result, err = client.DeallocateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) Deallocate(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeallocatePreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", nil, "Failure preparing request") + return + } + + resp, err := client.DeallocateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure sending request") + return + } + + result, err = client.DeallocateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Deallocate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeallocatePreparer prepares the Deallocate request. @@ -178,13 +205,14 @@ func (client VirtualMachineScaleSetsClient) DeallocateSender(req *http.Request) // DeallocateResponder handles the response to the Deallocate request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeallocateResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -194,24 +222,37 @@ func (client VirtualMachineScaleSetsClient) DeallocateResponder(resp *http.Respo // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) Delete(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmScaleSetName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) Delete(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, vmScaleSetName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -245,13 +286,14 @@ func (client VirtualMachineScaleSetsClient) DeleteSender(req *http.Request) (*ht // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -263,30 +305,46 @@ func (client VirtualMachineScaleSetsClient) DeleteResponder(resp *http.Response) // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. vmInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) DeleteInstances(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeleteInstances(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: vmInstanceIDs, Constraints: []validation.Constraint{{Target: "vmInstanceIDs.InstanceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances") - } - - req, err := client.DeleteInstancesPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", nil, "Failure preparing request") - } - - resp, err := client.DeleteInstancesSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure sending request") - } - - result, err = client.DeleteInstancesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeleteInstancesPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteInstancesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure sending request") + return + } + + result, err = client.DeleteInstancesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "DeleteInstances", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeleteInstancesPreparer prepares the DeleteInstances request. @@ -322,13 +380,14 @@ func (client VirtualMachineScaleSetsClient) DeleteInstancesSender(req *http.Requ // DeleteInstancesResponder handles the response to the DeleteInstances request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) DeleteInstancesResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) DeleteInstancesResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -339,13 +398,15 @@ func (client VirtualMachineScaleSetsClient) DeleteInstancesResponder(resp *http. func (client VirtualMachineScaleSetsClient) Get(resourceGroupName string, vmScaleSetName string) (result VirtualMachineScaleSet, err error) { req, err := client.GetPreparer(resourceGroupName, vmScaleSetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -403,13 +464,15 @@ func (client VirtualMachineScaleSetsClient) GetResponder(resp *http.Response) (r func (client VirtualMachineScaleSetsClient) GetInstanceView(resourceGroupName string, vmScaleSetName string) (result VirtualMachineScaleSetInstanceView, err error) { req, err := client.GetInstanceViewPreparer(resourceGroupName, vmScaleSetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", nil, "Failure preparing request") + return } resp, err := client.GetInstanceViewSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "GetInstanceView", resp, "Failure sending request") + return } result, err = client.GetInstanceViewResponder(resp) @@ -466,13 +529,15 @@ func (client VirtualMachineScaleSetsClient) GetInstanceViewResponder(resp *http. func (client VirtualMachineScaleSetsClient) List(resourceGroupName string) (result VirtualMachineScaleSetListResult, err error) { req, err := client.ListPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -553,13 +618,15 @@ func (client VirtualMachineScaleSetsClient) ListNextResults(lastResults VirtualM func (client VirtualMachineScaleSetsClient) ListAll() (result VirtualMachineScaleSetListWithLinkResult, err error) { req, err := client.ListAllPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", nil, "Failure preparing request") + return } resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListAll", resp, "Failure sending request") + return } result, err = client.ListAllResponder(resp) @@ -640,13 +707,15 @@ func (client VirtualMachineScaleSetsClient) ListAllNextResults(lastResults Virtu func (client VirtualMachineScaleSetsClient) ListSkus(resourceGroupName string, vmScaleSetName string) (result VirtualMachineScaleSetListSkusResult, err error) { req, err := client.ListSkusPreparer(resourceGroupName, vmScaleSetName) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", nil, "Failure preparing request") + return } resp, err := client.ListSkusSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ListSkus", resp, "Failure sending request") + return } result, err = client.ListSkusResponder(resp) @@ -731,24 +800,37 @@ func (client VirtualMachineScaleSetsClient) ListSkusNextResults(lastResults Virt // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. vmInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) PowerOff(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.PowerOffPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", nil, "Failure preparing request") - } - - resp, err := client.PowerOffSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure sending request") - } - - result, err = client.PowerOffResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) PowerOff(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PowerOffPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", nil, "Failure preparing request") + return + } + + resp, err := client.PowerOffSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure sending request") + return + } + + result, err = client.PowerOffResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "PowerOff", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PowerOffPreparer prepares the PowerOff request. @@ -787,13 +869,14 @@ func (client VirtualMachineScaleSetsClient) PowerOffSender(req *http.Request) (* // PowerOffResponder handles the response to the PowerOff request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) PowerOffResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -804,24 +887,37 @@ func (client VirtualMachineScaleSetsClient) PowerOffResponder(resp *http.Respons // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) Reimage(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", nil, "Failure preparing request") - } - - resp, err := client.ReimageSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure sending request") - } - - result, err = client.ReimageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) Reimage(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", nil, "Failure preparing request") + return + } + + resp, err := client.ReimageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure sending request") + return + } + + result, err = client.ReimageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimagePreparer prepares the Reimage request. @@ -855,13 +951,14 @@ func (client VirtualMachineScaleSetsClient) ReimageSender(req *http.Request) (*h // ReimageResponder handles the response to the Reimage request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) ReimageResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -873,24 +970,37 @@ func (client VirtualMachineScaleSetsClient) ReimageResponder(resp *http.Response // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. -func (client VirtualMachineScaleSetsClient) ReimageAll(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimageAllPreparer(resourceGroupName, vmScaleSetName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", nil, "Failure preparing request") - } - - resp, err := client.ReimageAllSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure sending request") - } - - result, err = client.ReimageAllResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) ReimageAll(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimageAllPreparer(resourceGroupName, vmScaleSetName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", nil, "Failure preparing request") + return + } + + resp, err := client.ReimageAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure sending request") + return + } + + result, err = client.ReimageAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "ReimageAll", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimageAllPreparer prepares the ReimageAll request. @@ -924,13 +1034,14 @@ func (client VirtualMachineScaleSetsClient) ReimageAllSender(req *http.Request) // ReimageAllResponder handles the response to the ReimageAll request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) ReimageAllResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) ReimageAllResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -942,24 +1053,37 @@ func (client VirtualMachineScaleSetsClient) ReimageAllResponder(resp *http.Respo // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. vmInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) Restart(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RestartPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", nil, "Failure preparing request") - } - - resp, err := client.RestartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure sending request") - } - - result, err = client.RestartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) Restart(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RestartPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", nil, "Failure preparing request") + return + } + + resp, err := client.RestartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure sending request") + return + } + + result, err = client.RestartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Restart", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RestartPreparer prepares the Restart request. @@ -998,13 +1122,14 @@ func (client VirtualMachineScaleSetsClient) RestartSender(req *http.Request) (*h // RestartResponder handles the response to the Restart request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) RestartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -1016,24 +1141,37 @@ func (client VirtualMachineScaleSetsClient) RestartResponder(resp *http.Response // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. vmInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) Start(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", nil, "Failure preparing request") - } - - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure sending request") - } - - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetsClient) Start(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. @@ -1072,13 +1210,14 @@ func (client VirtualMachineScaleSetsClient) StartSender(req *http.Request) (*htt // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) StartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -1090,30 +1229,46 @@ func (client VirtualMachineScaleSetsClient) StartResponder(resp *http.Response) // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. vmInstanceIDs is a list of virtual machine // instance IDs from the VM scale set. -func (client VirtualMachineScaleSetsClient) UpdateInstances(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) UpdateInstances(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: vmInstanceIDs, Constraints: []validation.Constraint{{Target: "vmInstanceIDs.InstanceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances") - } - - req, err := client.UpdateInstancesPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", nil, "Failure preparing request") - } - - resp, err := client.UpdateInstancesSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure sending request") - } - - result, err = client.UpdateInstancesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdateInstancesPreparer(resourceGroupName, vmScaleSetName, vmInstanceIDs, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateInstancesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure sending request") + return + } + + result, err = client.UpdateInstancesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "UpdateInstances", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdateInstancesPreparer prepares the UpdateInstances request. @@ -1149,12 +1304,13 @@ func (client VirtualMachineScaleSetsClient) UpdateInstancesSender(req *http.Requ // UpdateInstancesResponder handles the response to the UpdateInstances request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetsClient) UpdateInstancesResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetsClient) UpdateInstancesResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/compute/virtualmachinescalesetvms.go b/arm/compute/virtualmachinescalesetvms.go index 2079d509a6fd..ad0c535abebc 100755 --- a/arm/compute/virtualmachinescalesetvms.go +++ b/arm/compute/virtualmachinescalesetvms.go @@ -51,24 +51,37 @@ func NewVirtualMachineScaleSetVMsClientWithBaseURI(baseURI string, subscriptionI // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Deallocate(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeallocatePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", nil, "Failure preparing request") - } - - resp, err := client.DeallocateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure sending request") - } - - result, err = client.DeallocateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetVMsClient) Deallocate(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeallocatePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", nil, "Failure preparing request") + return + } + + resp, err := client.DeallocateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure sending request") + return + } + + result, err = client.DeallocateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeallocatePreparer prepares the Deallocate request. @@ -103,13 +116,14 @@ func (client VirtualMachineScaleSetVMsClient) DeallocateSender(req *http.Request // DeallocateResponder handles the response to the Deallocate request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -121,24 +135,37 @@ func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Res // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Delete(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetVMsClient) Delete(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -173,13 +200,14 @@ func (client VirtualMachineScaleSetVMsClient) DeleteSender(req *http.Request) (* // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -191,13 +219,15 @@ func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Respons func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, vmScaleSetName string, instanceID string) (result VirtualMachineScaleSetVM, err error) { req, err := client.GetPreparer(resourceGroupName, vmScaleSetName, instanceID) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -257,13 +287,15 @@ func (client VirtualMachineScaleSetVMsClient) GetResponder(resp *http.Response) func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName string, vmScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMInstanceView, err error) { req, err := client.GetInstanceViewPreparer(resourceGroupName, vmScaleSetName, instanceID) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", nil, "Failure preparing request") + return } resp, err := client.GetInstanceViewSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure sending request") + return } result, err = client.GetInstanceViewResponder(resp) @@ -324,13 +356,15 @@ func (client VirtualMachineScaleSetVMsClient) GetInstanceViewResponder(resp *htt func (client VirtualMachineScaleSetVMsClient) List(resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result VirtualMachineScaleSetVMListResult, err error) { req, err := client.ListPreparer(resourceGroupName, virtualMachineScaleSetName, filter, selectParameter, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -424,24 +458,37 @@ func (client VirtualMachineScaleSetVMsClient) ListNextResults(lastResults Virtua // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) PowerOff(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.PowerOffPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", nil, "Failure preparing request") - } - - resp, err := client.PowerOffSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure sending request") - } - - result, err = client.PowerOffResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetVMsClient) PowerOff(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PowerOffPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", nil, "Failure preparing request") + return + } + + resp, err := client.PowerOffSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure sending request") + return + } + + result, err = client.PowerOffResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PowerOffPreparer prepares the PowerOff request. @@ -476,13 +523,14 @@ func (client VirtualMachineScaleSetVMsClient) PowerOffSender(req *http.Request) // PowerOffResponder handles the response to the PowerOff request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -494,24 +542,37 @@ func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Respo // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Reimage(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request") - } - - resp, err := client.ReimageSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure sending request") - } - - result, err = client.ReimageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetVMsClient) Reimage(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request") + return + } + + resp, err := client.ReimageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure sending request") + return + } + + result, err = client.ReimageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimagePreparer prepares the Reimage request. @@ -546,13 +607,14 @@ func (client VirtualMachineScaleSetVMsClient) ReimageSender(req *http.Request) ( // ReimageResponder handles the response to the Reimage request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -565,24 +627,37 @@ func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Respon // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) ReimageAll(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ReimageAllPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", nil, "Failure preparing request") - } - - resp, err := client.ReimageAllSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure sending request") - } - - result, err = client.ReimageAllResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetVMsClient) ReimageAll(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ReimageAllPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", nil, "Failure preparing request") + return + } + + resp, err := client.ReimageAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure sending request") + return + } + + result, err = client.ReimageAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // ReimageAllPreparer prepares the ReimageAll request. @@ -617,13 +692,14 @@ func (client VirtualMachineScaleSetVMsClient) ReimageAllSender(req *http.Request // ReimageAllResponder handles the response to the ReimageAll request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -635,24 +711,37 @@ func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Res // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Restart(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RestartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", nil, "Failure preparing request") - } - - resp, err := client.RestartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure sending request") - } - - result, err = client.RestartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetVMsClient) Restart(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RestartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", nil, "Failure preparing request") + return + } + + resp, err := client.RestartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure sending request") + return + } + + result, err = client.RestartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RestartPreparer prepares the Restart request. @@ -687,13 +776,14 @@ func (client VirtualMachineScaleSetVMsClient) RestartSender(req *http.Request) ( // RestartResponder handles the response to the Restart request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -705,24 +795,37 @@ func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Respon // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the VM scale set. instanceID is the instance ID of the virtual // machine. -func (client VirtualMachineScaleSetVMsClient) Start(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", nil, "Failure preparing request") - } - - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure sending request") - } - - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure responding to request") - } - - return +func (client VirtualMachineScaleSetVMsClient) Start(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // StartPreparer prepares the Start request. @@ -757,12 +860,13 @@ func (client VirtualMachineScaleSetVMsClient) StartSender(req *http.Request) (*h // StartResponder handles the response to the Start request. The method always // closes the http.Response Body. -func (client VirtualMachineScaleSetVMsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { +func (client VirtualMachineScaleSetVMsClient) StartResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/compute/virtualmachinesizes.go b/arm/compute/virtualmachinesizes.go index 63a807aa719e..c76b203e7e9d 100755 --- a/arm/compute/virtualmachinesizes.go +++ b/arm/compute/virtualmachinesizes.go @@ -55,13 +55,15 @@ func (client VirtualMachineSizesClient) List(location string) (result VirtualMac req, err := client.ListPreparer(location) if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/consumption/client.go b/arm/consumption/client.go new file mode 100644 index 000000000000..54adcbaf10e0 --- /dev/null +++ b/arm/consumption/client.go @@ -0,0 +1,56 @@ +// Package consumption implements the Azure ARM Consumption service API version +// 2017-04-24-preview. +// +// Consumption management client provides access to consumption resources for +// Azure Web-Direct subscriptions. Other subscription types which were not +// purchased directly through the Azure web portal are not supported through +// this preview API. +package consumption + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Consumption + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Consumption. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/arm/consumption/models.go b/arm/consumption/models.go new file mode 100644 index 000000000000..49e06fe8cf23 --- /dev/null +++ b/arm/consumption/models.go @@ -0,0 +1,141 @@ +package consumption + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/shopspring/decimal" + "net/http" +) + +// ErrorDetails is the details of the error. +type ErrorDetails struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} + +// ErrorResponse is error response indicates that the service is not able to +// process the incoming request. The reason is provided in the error message. +type ErrorResponse struct { + Error *ErrorDetails `json:"error,omitempty"` +} + +// MeterDetails is the properties of the meter detail. +type MeterDetails struct { + MeterName *string `json:"meterName,omitempty"` + MeterCategory *string `json:"meterCategory,omitempty"` + MeterSubCategory *string `json:"meterSubCategory,omitempty"` + Unit *string `json:"unit,omitempty"` + MeterLocation *string `json:"meterLocation,omitempty"` + TotalIncludedQuantity *decimal.Decimal `json:"totalIncludedQuantity,omitempty"` + PretaxStandardRate *decimal.Decimal `json:"pretaxStandardRate,omitempty"` +} + +// Operation is a Consumption REST API operation. +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is the object that represents the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult is result of listing consumption operations. It contains +// a list of operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// Resource is the Resource model definition. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// UsageDetail is an usage detail resource. +type UsageDetail struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *UsageDetailProperties `json:"properties,omitempty"` +} + +// UsageDetailProperties is the properties of the usage detail. +type UsageDetailProperties struct { + BillingPeriodID *string `json:"billingPeriodId,omitempty"` + InvoiceID *string `json:"invoiceId,omitempty"` + UsageStart *date.Time `json:"usageStart,omitempty"` + UsageEnd *date.Time `json:"usageEnd,omitempty"` + InstanceName *string `json:"instanceName,omitempty"` + InstanceID *string `json:"instanceId,omitempty"` + InstanceLocation *string `json:"instanceLocation,omitempty"` + Currency *string `json:"currency,omitempty"` + UsageQuantity *decimal.Decimal `json:"usageQuantity,omitempty"` + BillableQuantity *decimal.Decimal `json:"billableQuantity,omitempty"` + PretaxCost *decimal.Decimal `json:"pretaxCost,omitempty"` + IsEstimated *bool `json:"isEstimated,omitempty"` + MeterID *string `json:"meterId,omitempty"` + MeterDetails *MeterDetails `json:"meterDetails,omitempty"` + AdditionalProperties *map[string]*string `json:"additionalProperties,omitempty"` +} + +// UsageDetailsListResult is result of listing usage details. It contains a +// list of available usage details in reverse chronological order by billing +// period. +type UsageDetailsListResult struct { + autorest.Response `json:"-"` + Value *[]UsageDetail `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// UsageDetailsListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client UsageDetailsListResult) UsageDetailsListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} diff --git a/arm/consumption/operations.go b/arm/consumption/operations.go new file mode 100644 index 000000000000..d4d0b313dc34 --- /dev/null +++ b/arm/consumption/operations.go @@ -0,0 +1,125 @@ +package consumption + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the consumption management client provides access to +// consumption resources for Azure Web-Direct subscriptions. Other subscription +// types which were not purchased directly through the Azure web portal are not +// supported through this preview API. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available consumption REST API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2017-04-24-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Consumption/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "consumption.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "consumption.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/consumption/usagedetails.go b/arm/consumption/usagedetails.go new file mode 100644 index 000000000000..f60768e7304f --- /dev/null +++ b/arm/consumption/usagedetails.go @@ -0,0 +1,170 @@ +package consumption + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// UsageDetailsClient is the consumption management client provides access to +// consumption resources for Azure Web-Direct subscriptions. Other subscription +// types which were not purchased directly through the Azure web portal are not +// supported through this preview API. +type UsageDetailsClient struct { + ManagementClient +} + +// NewUsageDetailsClient creates an instance of the UsageDetailsClient client. +func NewUsageDetailsClient(subscriptionID string) UsageDetailsClient { + return NewUsageDetailsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsageDetailsClientWithBaseURI creates an instance of the +// UsageDetailsClient client. +func NewUsageDetailsClientWithBaseURI(baseURI string, subscriptionID string) UsageDetailsClient { + return UsageDetailsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the usage details for a scope in reverse chronological order by +// billing period. Usage details are available via this API only for January 1, +// 2017 or later. +// +// scope is the scope of the usage details. The scope can be +// '/subscriptions/{subscriptionId}/' for a subscription, or +// '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}' +// for an invoice or +// '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}' +// for a billing perdiod. expand is may be used to expand the +// additionalProperties or meterDetails property within a list of usage +// details. By default, these fields are not included when listing usage +// details. filter is may be used to filter usageDetails by usageEnd (Utc +// time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does +// not currently support 'ne', 'or', or 'not'. skiptoken is skiptoken is only +// used if a previous operation returned a partial result. If a previous +// response contains a nextLink element, the value of the nextLink element will +// include a skiptoken parameter that specifies a starting point to use for +// subsequent calls. top is may be used to limit the number of results to the +// most recent N usageDetails. +func (client UsageDetailsClient) List(scope string, expand string, filter string, skiptoken string, top *int32) (result UsageDetailsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "consumption.UsageDetailsClient", "List") + } + + req, err := client.ListPreparer(scope, expand, filter, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.UsageDetailsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.UsageDetailsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.UsageDetailsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client UsageDetailsClient) ListPreparer(scope string, expand string, filter string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": autorest.Encode("path", scope), + } + + const APIVersion = "2017-04-24-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Consumption/usageDetails", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UsageDetailsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UsageDetailsClient) ListResponder(resp *http.Response) (result UsageDetailsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client UsageDetailsClient) ListNextResults(lastResults UsageDetailsListResult) (result UsageDetailsListResult, err error) { + req, err := lastResults.UsageDetailsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "consumption.UsageDetailsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "consumption.UsageDetailsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.UsageDetailsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/consumption/version.go b/arm/consumption/version.go new file mode 100644 index 000000000000..d0e78a167155 --- /dev/null +++ b/arm/consumption/version.go @@ -0,0 +1,29 @@ +package consumption + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.0.0-beta arm-consumption/2017-04-24-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.0.0-beta" +} diff --git a/arm/containerregistry/client.go b/arm/containerregistry/client.go index 4c2e1f90d4da..5195d1f8ac99 100755 --- a/arm/containerregistry/client.go +++ b/arm/containerregistry/client.go @@ -1,5 +1,5 @@ // Package containerregistry implements the Azure ARM Containerregistry service -// API version 2016-06-27-preview. +// API version 2017-06-01-preview. // // package containerregistry diff --git a/arm/containerregistry/models.go b/arm/containerregistry/models.go index 9d201d73e184..c3be3a10a4f3 100755 --- a/arm/containerregistry/models.go +++ b/arm/containerregistry/models.go @@ -25,6 +25,179 @@ import ( "net/http" ) +// PasswordName enumerates the values for password name. +type PasswordName string + +const ( + // Password specifies the password state for password name. + Password PasswordName = "password" + // Password2 specifies the password 2 state for password name. + Password2 PasswordName = "password2" +) + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Creating specifies the creating state for provisioning state. + Creating ProvisioningState = "Creating" + // Succeeded specifies the succeeded state for provisioning state. + Succeeded ProvisioningState = "Succeeded" +) + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // Basic specifies the basic state for sku name. + Basic SkuName = "Basic" + // Premium specifies the premium state for sku name. + Premium SkuName = "Premium" + // Standard specifies the standard state for sku name. + Standard SkuName = "Standard" +) + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // SkuTierBasic specifies the sku tier basic state for sku tier. + SkuTierBasic SkuTier = "Basic" + // SkuTierPremium specifies the sku tier premium state for sku tier. + SkuTierPremium SkuTier = "Premium" + // SkuTierStandard specifies the sku tier standard state for sku tier. + SkuTierStandard SkuTier = "Standard" +) + +// WebhookAction enumerates the values for webhook action. +type WebhookAction string + +const ( + // Delete specifies the delete state for webhook action. + Delete WebhookAction = "delete" + // Pull specifies the pull state for webhook action. + Pull WebhookAction = "pull" + // Push specifies the push state for webhook action. + Push WebhookAction = "push" +) + +// Actor is the agent that initiated the event. For most situations, this could +// be from the authorization context of the request. +type Actor struct { + Name *string `json:"name,omitempty"` +} + +// CallbackConfig is the configuration of service URI and custom headers for +// the webhook. +type CallbackConfig struct { + autorest.Response `json:"-"` + ServiceURI *string `json:"serviceUri,omitempty"` + CustomHeaders *map[string]*string `json:"customHeaders,omitempty"` +} + +// Event is the event for a webhook. +type Event struct { + ID *string `json:"id,omitempty"` + EventRequestMessage *EventRequestMessage `json:"eventRequestMessage,omitempty"` + EventResponseMessage *EventResponseMessage `json:"eventResponseMessage,omitempty"` +} + +// EventContent is the content of the event request message. +type EventContent struct { + ID *string `json:"id,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Action *string `json:"action,omitempty"` + Target *Target `json:"target,omitempty"` + Request *Request `json:"request,omitempty"` + Actor *Actor `json:"actor,omitempty"` + Source *Source `json:"source,omitempty"` +} + +// EventInfo is the basic information of an event. +type EventInfo struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` +} + +// EventListResult is the result of a request to list events for a webhook. +type EventListResult struct { + autorest.Response `json:"-"` + Value *[]Event `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// EventListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client EventListResult) EventListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// EventRequestMessage is the event request message sent to the service URI. +type EventRequestMessage struct { + Content *EventContent `json:"content,omitempty"` + Headers *map[string]*string `json:"headers,omitempty"` + Method *string `json:"method,omitempty"` + RequestURI *string `json:"requestUri,omitempty"` + Version *string `json:"version,omitempty"` +} + +// EventResponseMessage is the event response message received from the service +// URI. +type EventResponseMessage struct { + Content *string `json:"content,omitempty"` + Headers *map[string]*string `json:"headers,omitempty"` + ReasonPhrase *string `json:"reasonPhrase,omitempty"` + StatusCode *string `json:"statusCode,omitempty"` + Version *string `json:"version,omitempty"` +} + +// OperationDefinition is the definition of a container registry operation. +type OperationDefinition struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplayDefinition `json:"display,omitempty"` +} + +// OperationDisplayDefinition is the display information for a container +// registry operation. +type OperationDisplayDefinition struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` + Description *string `json:"description,omitempty"` +} + +// OperationListResult is the result of a request to list container registry +// operations. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]OperationDefinition `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RegenerateCredentialParameters is the parameters used to regenerate the +// login credential. +type RegenerateCredentialParameters struct { + Name PasswordName `json:"name,omitempty"` +} + // Registry is an object that represents a container registry. type Registry struct { autorest.Response `json:"-"` @@ -33,15 +206,25 @@ type Registry struct { Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Sku *Sku `json:"sku,omitempty"` *RegistryProperties `json:"properties,omitempty"` } -// RegistryCredentials is the result of a request to get the administrator -// login credentials for a container registry. -type RegistryCredentials struct { +// RegistryCreateParameters is the parameters for creating a container +// registry. +type RegistryCreateParameters struct { + Tags *map[string]*string `json:"tags,omitempty"` + Location *string `json:"location,omitempty"` + Sku *Sku `json:"sku,omitempty"` + *RegistryPropertiesCreateParameters `json:"properties,omitempty"` +} + +// RegistryListCredentialsResult is the response from the ListCredentials +// operation. +type RegistryListCredentialsResult struct { autorest.Response `json:"-"` - Username *string `json:"username,omitempty"` - Password *string `json:"password,omitempty"` + Username *string `json:"username,omitempty"` + Passwords *[]RegistryPassword `json:"passwords,omitempty"` } // RegistryListResult is the result of a request to list container registries. @@ -63,8 +246,8 @@ func (client RegistryListResult) RegistryListResultPreparer() (*http.Request, er autorest.WithBaseURL(to.String(client.NextLink))) } -// RegistryNameCheckRequest is a request to check whether the container -// registry name is available. +// RegistryNameCheckRequest is a request to check whether a container registry +// name is available. type RegistryNameCheckRequest struct { Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` @@ -79,19 +262,33 @@ type RegistryNameStatus struct { Message *string `json:"message,omitempty"` } +// RegistryPassword is the login password for the container registry. +type RegistryPassword struct { + Name PasswordName `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + // RegistryProperties is the properties of a container registry. type RegistryProperties struct { - LoginServer *string `json:"loginServer,omitempty"` - CreationDate *date.Time `json:"creationDate,omitempty"` + LoginServer *string `json:"loginServer,omitempty"` + CreationDate *date.Time `json:"creationDate,omitempty"` + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` +} + +// RegistryPropertiesCreateParameters is the parameters for creating the +// properties of a container registry. +type RegistryPropertiesCreateParameters struct { AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` - StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` + StorageAccount *StorageAccountParameters `json:"storageAccount,omitempty"` } // RegistryPropertiesUpdateParameters is the parameters for updating the // properties of a container registry. type RegistryPropertiesUpdateParameters struct { AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` - StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` + StorageAccount *StorageAccountParameters `json:"storageAccount,omitempty"` } // RegistryUpdateParameters is the parameters for updating a container @@ -101,6 +298,52 @@ type RegistryUpdateParameters struct { *RegistryPropertiesUpdateParameters `json:"properties,omitempty"` } +// Replication is an object that represents a replication for a container +// registry. +type Replication struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ReplicationProperties `json:"properties,omitempty"` +} + +// ReplicationListResult is the result of a request to list replications for a +// container registry. +type ReplicationListResult struct { + autorest.Response `json:"-"` + Value *[]Replication `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ReplicationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ReplicationListResult) ReplicationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ReplicationProperties is the properties of a replication. +type ReplicationProperties struct { + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// Request is the request that generated the event. +type Request struct { + ID *string `json:"id,omitempty"` + Addr *string `json:"addr,omitempty"` + Host *string `json:"host,omitempty"` + Method *string `json:"method,omitempty"` + Useragent *string `json:"useragent,omitempty"` +} + // Resource is an Azure resource. type Resource struct { ID *string `json:"id,omitempty"` @@ -110,9 +353,110 @@ type Resource struct { Tags *map[string]*string `json:"tags,omitempty"` } -// StorageAccountProperties is the properties of a storage account for a -// container registry. -type StorageAccountProperties struct { +// Sku is the SKU of a container registry. +type Sku struct { + Name SkuName `json:"name,omitempty"` + Tier SkuTier `json:"tier,omitempty"` +} + +// Source is the registry node that generated the event. Put differently, while +// the actor initiates the event, the source generates it. +type Source struct { + Addr *string `json:"addr,omitempty"` + InstanceID *string `json:"instanceID,omitempty"` +} + +// StorageAccountParameters is the parameters of a storage account for a +// container registry. Only applicable to Basic SKU. +type StorageAccountParameters struct { Name *string `json:"name,omitempty"` AccessKey *string `json:"accessKey,omitempty"` } + +// StorageAccountProperties is the properties of a storage account for a +// container registry. Only applicable to Basic SKU. +type StorageAccountProperties struct { + Name *string `json:"name,omitempty"` +} + +// Target is the target of the event. +type Target struct { + MediaType *string `json:"mediaType,omitempty"` + Size *int64 `json:"size,omitempty"` + Digest *string `json:"digest,omitempty"` + Length *int64 `json:"length,omitempty"` + Repository *string `json:"repository,omitempty"` + URL *string `json:"url,omitempty"` + Tag *string `json:"tag,omitempty"` +} + +// Webhook is an object that represents a webhook for a container registry. +type Webhook struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *WebhookProperties `json:"properties,omitempty"` +} + +// WebhookCreateParameters is the parameters for creating a webhook. +type WebhookCreateParameters struct { + Tags *map[string]*string `json:"tags,omitempty"` + Location *string `json:"location,omitempty"` + *WebhookPropertiesCreateParameters `json:"properties,omitempty"` +} + +// WebhookListResult is the result of a request to list webhooks for a +// container registry. +type WebhookListResult struct { + autorest.Response `json:"-"` + Value *[]Webhook `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// WebhookListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client WebhookListResult) WebhookListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// WebhookProperties is the properties of a webhook. +type WebhookProperties struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + Scope *string `json:"scope,omitempty"` + Actions *[]WebhookAction `json:"actions,omitempty"` +} + +// WebhookPropertiesCreateParameters is the parameters for creating the +// properties of a webhook. +type WebhookPropertiesCreateParameters struct { + ServiceURI *string `json:"serviceUri,omitempty"` + CustomHeaders *map[string]*string `json:"customHeaders,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Scope *string `json:"scope,omitempty"` + Actions *[]WebhookAction `json:"actions,omitempty"` +} + +// WebhookPropertiesUpdateParameters is the parameters for updating the +// properties of a webhook. +type WebhookPropertiesUpdateParameters struct { + ServiceURI *string `json:"serviceUri,omitempty"` + CustomHeaders *map[string]*string `json:"customHeaders,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Scope *string `json:"scope,omitempty"` + Actions *[]WebhookAction `json:"actions,omitempty"` +} + +// WebhookUpdateParameters is the parameters for updating a webhook. +type WebhookUpdateParameters struct { + Tags *map[string]*string `json:"tags,omitempty"` + *WebhookPropertiesUpdateParameters `json:"properties,omitempty"` +} diff --git a/arm/containerregistry/operations.go b/arm/containerregistry/operations.go new file mode 100644 index 000000000000..3c50861f286e --- /dev/null +++ b/arm/containerregistry/operations.go @@ -0,0 +1,124 @@ +package containerregistry + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the +// Containerregistry service. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Azure Container Registry REST API +// operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ContainerRegistry/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/containerregistry/registries.go b/arm/containerregistry/registries.go index 186d010f6666..dec3a2b74327 100755 --- a/arm/containerregistry/registries.go +++ b/arm/containerregistry/registries.go @@ -44,27 +44,33 @@ func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) Regis // CheckNameAvailability checks whether the container registry name is // available for use. The name must contain only alphanumeric characters, be -// globally unique, and between 5 and 60 characters in length. +// globally unique, and between 5 and 50 characters in length. // // registryNameCheckRequest is the object containing information for the // availability request. func (client RegistriesClient) CheckNameAvailability(registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: registryNameCheckRequest, - Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, Chain: nil}, + Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}, + }}, {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CheckNameAvailability") } req, err := client.CheckNameAvailabilityPreparer(registryNameCheckRequest) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckNameAvailabilityResponder(resp) @@ -81,7 +87,7 @@ func (client RegistriesClient) CheckNameAvailabilityPreparer(registryNameCheckRe "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -115,52 +121,77 @@ func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Respons return } -// CreateOrUpdate creates or updates a container registry with the specified -// parameters. +// Create creates a container registry with the specified parameters. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. -// registry is the parameters for creating or updating a container registry. -func (client RegistriesClient) CreateOrUpdate(resourceGroupName string, registryName string, registry Registry) (result Registry, err error) { +// registryCreateParameters is the parameters for creating a container +// registry. +func (client RegistriesClient) Create(resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters, cancel <-chan struct{}) (<-chan Registry, <-chan error) { + resultChan := make(chan Registry, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ - {TargetValue: registry, - Constraints: []validation.Constraint{{Target: "registry.RegistryProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "registry.RegistryProperties.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, - }}, - }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, registryName, registry) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client RegistriesClient) CreateOrUpdatePreparer(resourceGroupName string, registryName string, registry Registry) (*http.Request, error) { + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: registryCreateParameters, + Constraints: []validation.Constraint{{Target: "registryCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "registryCreateParameters.Sku", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "registryCreateParameters.RegistryPropertiesCreateParameters", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Registry + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, registryName, registryCreateParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client RegistriesClient) CreatePreparer(resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "registryName": autorest.Encode("path", registryName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -170,20 +201,22 @@ func (client RegistriesClient) CreateOrUpdatePreparer(resourceGroupName string, autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), - autorest.WithJSON(registry), + autorest.WithJSON(registryCreateParameters), autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) + return preparer.Prepare(&http.Request{Cancel: cancel}) } -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// CreateSender sends the Create request. The method will close the // http.Response Body if it receives an error. -func (client RegistriesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) +func (client RegistriesClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) } -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client RegistriesClient) CreateOrUpdateResponder(resp *http.Response) (result Registry, err error) { +func (client RegistriesClient) CreateResponder(resp *http.Response) (result Registry, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -194,39 +227,65 @@ func (client RegistriesClient) CreateOrUpdateResponder(resp *http.Response) (res return } -// Delete deletes a container registry. +// Delete deletes a container registry. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. -func (client RegistriesClient) Delete(resourceGroupName string, registryName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, registryName) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure responding to request") - } - - return +func (client RegistriesClient) Delete(resourceGroupName string, registryName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, registryName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. -func (client RegistriesClient) DeletePreparer(resourceGroupName string, registryName string) (*http.Request, error) { +func (client RegistriesClient) DeletePreparer(resourceGroupName string, registryName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "registryName": autorest.Encode("path", registryName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -236,13 +295,15 @@ func (client RegistriesClient) DeletePreparer(resourceGroupName string, registry autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. func (client RegistriesClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) } // DeleteResponder handles the response to the Delete request. The method always @@ -251,110 +312,55 @@ func (client RegistriesClient) DeleteResponder(resp *http.Response) (result auto err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return } -// GetCredentials gets the administrator login credentials for the specified -// container registry. +// Get gets the properties of the specified container registry. // // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. -func (client RegistriesClient) GetCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { - req, err := client.GetCredentialsPreparer(resourceGroupName, registryName) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", nil, "Failure preparing request") - } - - resp, err := client.GetCredentialsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure sending request") +func (client RegistriesClient) Get(resourceGroupName string, registryName string) (result Registry, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Get") } - result, err = client.GetCredentialsResponder(resp) + req, err := client.GetPreparer(resourceGroupName, registryName) if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure responding to request") - } - - return -} - -// GetCredentialsPreparer prepares the GetCredentials request. -func (client RegistriesClient) GetCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2016-06-27-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getCredentials", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetCredentialsSender sends the GetCredentials request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) GetCredentialsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetCredentialsResponder handles the response to the GetCredentials request. The method always -// closes the http.Response Body. -func (client RegistriesClient) GetCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetProperties gets the properties of the specified container registry. -// -// resourceGroupName is the name of the resource group to which the container -// registry belongs. registryName is the name of the container registry. -func (client RegistriesClient) GetProperties(resourceGroupName string, registryName string) (result Registry, err error) { - req, err := client.GetPropertiesPreparer(resourceGroupName, registryName) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil, "Failure preparing request") + return } - resp, err := client.GetPropertiesSender(req) + resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request") + return } - result, err = client.GetPropertiesResponder(resp) + result, err = client.GetResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request") } return } -// GetPropertiesPreparer prepares the GetProperties request. -func (client RegistriesClient) GetPropertiesPreparer(resourceGroupName string, registryName string) (*http.Request, error) { +// GetPreparer prepares the Get request. +func (client RegistriesClient) GetPreparer(resourceGroupName string, registryName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "registryName": autorest.Encode("path", registryName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -367,15 +373,15 @@ func (client RegistriesClient) GetPropertiesPreparer(resourceGroupName string, r return preparer.Prepare(&http.Request{}) } -// GetPropertiesSender sends the GetProperties request. The method will close the +// GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. -func (client RegistriesClient) GetPropertiesSender(req *http.Request) (*http.Response, error) { +func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// GetPropertiesResponder handles the response to the GetProperties request. The method always +// GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client RegistriesClient) GetPropertiesResponder(resp *http.Response) (result Registry, err error) { +func (client RegistriesClient) GetResponder(resp *http.Response) (result Registry, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -386,18 +392,19 @@ func (client RegistriesClient) GetPropertiesResponder(resp *http.Response) (resu return } -// List lists all the available container registries under the specified -// subscription. +// List lists all the container registries under the specified subscription. func (client RegistriesClient) List() (result RegistryListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -414,7 +421,7 @@ func (client RegistriesClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -470,21 +477,23 @@ func (client RegistriesClient) ListNextResults(lastResults RegistryListResult) ( return } -// ListByResourceGroup lists all the available container registries under the -// specified resource group. +// ListByResourceGroup lists all the container registries under the specified +// resource group. // // resourceGroupName is the name of the resource group to which the container // registry belongs. func (client RegistriesClient) ListByResourceGroup(resourceGroupName string) (result RegistryListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -502,7 +511,7 @@ func (client RegistriesClient) ListByResourceGroupPreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -558,40 +567,50 @@ func (client RegistriesClient) ListByResourceGroupNextResults(lastResults Regist return } -// RegenerateCredentials regenerates the administrator login credentials for -// the specified container registry. +// ListCredentials lists the login credentials for the specified container +// registry. // // resourceGroupName is the name of the resource group to which the container // registry belongs. registryName is the name of the container registry. -func (client RegistriesClient) RegenerateCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { - req, err := client.RegenerateCredentialsPreparer(resourceGroupName, registryName) +func (client RegistriesClient) ListCredentials(resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "ListCredentials") + } + + req, err := client.ListCredentialsPreparer(resourceGroupName, registryName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request") + return } - resp, err := client.RegenerateCredentialsSender(req) + resp, err := client.ListCredentialsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request") + return } - result, err = client.RegenerateCredentialsResponder(resp) + result, err = client.ListCredentialsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request") } return } -// RegenerateCredentialsPreparer prepares the RegenerateCredentials request. -func (client RegistriesClient) RegenerateCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { +// ListCredentialsPreparer prepares the ListCredentials request. +func (client RegistriesClient) ListCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "registryName": autorest.Encode("path", registryName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -599,20 +618,99 @@ func (client RegistriesClient) RegenerateCredentialsPreparer(resourceGroupName s preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredentials", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// RegenerateCredentialsSender sends the RegenerateCredentials request. The method will close the +// ListCredentialsSender sends the ListCredentials request. The method will close the // http.Response Body if it receives an error. -func (client RegistriesClient) RegenerateCredentialsSender(req *http.Request) (*http.Response, error) { +func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// RegenerateCredentialsResponder handles the response to the RegenerateCredentials request. The method always +// ListCredentialsResponder handles the response to the ListCredentials request. The method always // closes the http.Response Body. -func (client RegistriesClient) RegenerateCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) { +func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateCredential regenerates one of the login credentials for the +// specified container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// regenerateCredentialParameters is specifies name of the password which +// should be regenerated -- password or password2. +func (client RegistriesClient) RegenerateCredential(resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "RegenerateCredential") + } + + req, err := client.RegenerateCredentialPreparer(resourceGroupName, registryName, regenerateCredentialParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateCredentialSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request") + return + } + + result, err = client.RegenerateCredentialResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request") + } + + return +} + +// RegenerateCredentialPreparer prepares the RegenerateCredential request. +func (client RegistriesClient) RegenerateCredentialPreparer(resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", pathParameters), + autorest.WithJSON(regenerateCredentialParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always +// closes the http.Response Body. +func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -630,15 +728,25 @@ func (client RegistriesClient) RegenerateCredentialsResponder(resp *http.Respons // registryUpdateParameters is the parameters for updating a container // registry. func (client RegistriesClient) Update(resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result Registry, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Update") + } + req, err := client.UpdatePreparer(resourceGroupName, registryName, registryUpdateParameters) if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -657,7 +765,7 @@ func (client RegistriesClient) UpdatePreparer(resourceGroupName string, registry "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-06-27-preview" + const APIVersion = "2017-06-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/containerregistry/replications.go b/arm/containerregistry/replications.go new file mode 100644 index 000000000000..a651b0d7a796 --- /dev/null +++ b/arm/containerregistry/replications.go @@ -0,0 +1,421 @@ +package containerregistry + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ReplicationsClient is the client for the Replications methods of the +// Containerregistry service. +type ReplicationsClient struct { + ManagementClient +} + +// NewReplicationsClient creates an instance of the ReplicationsClient client. +func NewReplicationsClient(subscriptionID string) ReplicationsClient { + return NewReplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReplicationsClientWithBaseURI creates an instance of the +// ReplicationsClient client. +func NewReplicationsClientWithBaseURI(baseURI string, subscriptionID string) ReplicationsClient { + return ReplicationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a replication for a container registry +// with the specified parameters. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// replicationName is the name of the replication. replication is the +// parameters for creating a replication. +func (client ReplicationsClient) CreateOrUpdate(resourceGroupName string, registryName string, replicationName string, replication Replication, cancel <-chan struct{}) (<-chan Replication, <-chan error) { + resultChan := make(chan Replication, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: replicationName, + Constraints: []validation.Constraint{{Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "containerregistry.ReplicationsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Replication + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, registryName, replicationName, replication, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ReplicationsClient) CreateOrUpdatePreparer(resourceGroupName string, registryName string, replicationName string, replication Replication, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "replicationName": autorest.Encode("path", replicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", pathParameters), + autorest.WithJSON(replication), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ReplicationsClient) CreateOrUpdateResponder(resp *http.Response) (result Replication, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a replication from a container registry. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// replicationName is the name of the replication. +func (client ReplicationsClient) Delete(resourceGroupName string, registryName string, replicationName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: replicationName, + Constraints: []validation.Constraint{{Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "containerregistry.ReplicationsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, registryName, replicationName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationsClient) DeletePreparer(resourceGroupName string, registryName string, replicationName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "replicationName": autorest.Encode("path", replicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified replication. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// replicationName is the name of the replication. +func (client ReplicationsClient) Get(resourceGroupName string, registryName string, replicationName string) (result Replication, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: replicationName, + Constraints: []validation.Constraint{{Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.ReplicationsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, registryName, replicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationsClient) GetPreparer(resourceGroupName string, registryName string, replicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "replicationName": autorest.Encode("path", replicationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationsClient) GetResponder(resp *http.Response) (result Replication, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the replications for the specified container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +func (client ReplicationsClient) List(resourceGroupName string, registryName string) (result ReplicationListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.ReplicationsClient", "List") + } + + req, err := client.ListPreparer(resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationsClient) ListPreparer(resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationsClient) ListResponder(resp *http.Response) (result ReplicationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationsClient) ListNextResults(lastResults ReplicationListResult) (result ReplicationListResult, err error) { + req, err := lastResults.ReplicationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/containerregistry/version.go b/arm/containerregistry/version.go index 2a02a3ee90ae..976c191dd51f 100755 --- a/arm/containerregistry/version.go +++ b/arm/containerregistry/version.go @@ -20,10 +20,10 @@ package containerregistry // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-containerregistry/2016-06-27-preview" + return "Azure-SDK-For-Go/v10.0.0-beta arm-containerregistry/2017-06-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/containerregistry/webhooks.go b/arm/containerregistry/webhooks.go new file mode 100644 index 000000000000..5bec6b7f53d7 --- /dev/null +++ b/arm/containerregistry/webhooks.go @@ -0,0 +1,775 @@ +package containerregistry + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// WebhooksClient is the client for the Webhooks methods of the +// Containerregistry service. +type WebhooksClient struct { + ManagementClient +} + +// NewWebhooksClient creates an instance of the WebhooksClient client. +func NewWebhooksClient(subscriptionID string) WebhooksClient { + return NewWebhooksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWebhooksClientWithBaseURI creates an instance of the WebhooksClient +// client. +func NewWebhooksClientWithBaseURI(baseURI string, subscriptionID string) WebhooksClient { + return WebhooksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a webhook for a container registry with the specified +// parameters. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// webhookName is the name of the webhook. webhookCreateParameters is the +// parameters for creating a webhook. +func (client WebhooksClient) Create(resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters, cancel <-chan struct{}) (<-chan Webhook, <-chan error) { + resultChan := make(chan Webhook, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookName, + Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookCreateParameters, + Constraints: []validation.Constraint{{Target: "webhookCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "webhookCreateParameters.WebhookPropertiesCreateParameters", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "webhookCreateParameters.WebhookPropertiesCreateParameters.ServiceURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "webhookCreateParameters.WebhookPropertiesCreateParameters.Actions", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Webhook + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, registryName, webhookName, webhookCreateParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client WebhooksClient) CreatePreparer(resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(webhookCreateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client WebhooksClient) CreateResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a webhook from a container registry. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// webhookName is the name of the webhook. +func (client WebhooksClient) Delete(resourceGroupName string, registryName string, webhookName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookName, + Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, registryName, webhookName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client WebhooksClient) DeletePreparer(resourceGroupName string, registryName string, webhookName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WebhooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified webhook. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// webhookName is the name of the webhook. +func (client WebhooksClient) Get(resourceGroupName string, registryName string, webhookName string) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookName, + Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WebhooksClient) GetPreparer(resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WebhooksClient) GetResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCallbackConfig gets the configuration of service URI and custom headers +// for the webhook. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// webhookName is the name of the webhook. +func (client WebhooksClient) GetCallbackConfig(resourceGroupName string, registryName string, webhookName string) (result CallbackConfig, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookName, + Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "GetCallbackConfig") + } + + req, err := client.GetCallbackConfigPreparer(resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", nil, "Failure preparing request") + return + } + + resp, err := client.GetCallbackConfigSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", resp, "Failure sending request") + return + } + + result, err = client.GetCallbackConfigResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", resp, "Failure responding to request") + } + + return +} + +// GetCallbackConfigPreparer prepares the GetCallbackConfig request. +func (client WebhooksClient) GetCallbackConfigPreparer(resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetCallbackConfigSender sends the GetCallbackConfig request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) GetCallbackConfigSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetCallbackConfigResponder handles the response to the GetCallbackConfig request. The method always +// closes the http.Response Body. +func (client WebhooksClient) GetCallbackConfigResponder(resp *http.Response) (result CallbackConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the webhooks for the specified container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +func (client WebhooksClient) List(resourceGroupName string, registryName string) (result WebhookListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "List") + } + + req, err := client.ListPreparer(resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client WebhooksClient) ListPreparer(resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WebhooksClient) ListResponder(resp *http.Response) (result WebhookListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client WebhooksClient) ListNextResults(lastResults WebhookListResult) (result WebhookListResult, err error) { + req, err := lastResults.WebhookListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListEvents lists recent events for the specified webhook. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// webhookName is the name of the webhook. +func (client WebhooksClient) ListEvents(resourceGroupName string, registryName string, webhookName string) (result EventListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookName, + Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "ListEvents") + } + + req, err := client.ListEventsPreparer(resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", nil, "Failure preparing request") + return + } + + resp, err := client.ListEventsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure sending request") + return + } + + result, err = client.ListEventsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure responding to request") + } + + return +} + +// ListEventsPreparer prepares the ListEvents request. +func (client WebhooksClient) ListEventsPreparer(resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListEventsSender sends the ListEvents request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) ListEventsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListEventsResponder handles the response to the ListEvents request. The method always +// closes the http.Response Body. +func (client WebhooksClient) ListEventsResponder(resp *http.Response) (result EventListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListEventsNextResults retrieves the next set of results, if any. +func (client WebhooksClient) ListEventsNextResults(lastResults EventListResult) (result EventListResult, err error) { + req, err := lastResults.EventListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListEventsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure sending next results request") + } + + result, err = client.ListEventsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure responding to next results request") + } + + return +} + +// Ping triggers a ping event to be sent to the webhook. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// webhookName is the name of the webhook. +func (client WebhooksClient) Ping(resourceGroupName string, registryName string, webhookName string) (result EventInfo, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookName, + Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "Ping") + } + + req, err := client.PingPreparer(resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", nil, "Failure preparing request") + return + } + + resp, err := client.PingSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", resp, "Failure sending request") + return + } + + result, err = client.PingResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", resp, "Failure responding to request") + } + + return +} + +// PingPreparer prepares the Ping request. +func (client WebhooksClient) PingPreparer(resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// PingSender sends the Ping request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) PingSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// PingResponder handles the response to the Ping request. The method always +// closes the http.Response Body. +func (client WebhooksClient) PingResponder(resp *http.Response) (result EventInfo, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a webhook with the specified parameters. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// webhookName is the name of the webhook. webhookUpdateParameters is the +// parameters for updating a webhook. +func (client WebhooksClient) Update(resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters) (result Webhook, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryName, + Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, + {TargetValue: webhookName, + Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.WebhooksClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, registryName, webhookName, webhookUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WebhooksClient) UpdatePreparer(resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webhookName": autorest.Encode("path", webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), + autorest.WithJSON(webhookUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WebhooksClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WebhooksClient) UpdateResponder(resp *http.Response) (result Webhook, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/containerservice/client.go b/arm/containerservice/client.go index a2cdfdf7e37c..7aefda8a8ef0 100755 --- a/arm/containerservice/client.go +++ b/arm/containerservice/client.go @@ -1,5 +1,5 @@ // Package containerservice implements the Azure ARM Containerservice service -// API version 2016-09-30. +// API version 2017-01-31. // // The Container Service Client. package containerservice diff --git a/arm/containerservice/containerservices.go b/arm/containerservice/containerservices.go index d700024c838b..6fca953c88f1 100755 --- a/arm/containerservice/containerservices.go +++ b/arm/containerservice/containerservices.go @@ -52,7 +52,9 @@ func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string // the name of the container service in the specified subscription and resource // group. parameters is parameters supplied to the Create or Update a Container // Service operation. -func (client ContainerServicesClient) CreateOrUpdate(resourceGroupName string, containerServiceName string, parameters ContainerService, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ContainerServicesClient) CreateOrUpdate(resourceGroupName string, containerServiceName string, parameters ContainerService, cancel <-chan struct{}) (<-chan ContainerService, <-chan error) { + resultChan := make(chan ContainerService, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false, @@ -82,26 +84,40 @@ func (client ContainerServicesClient) CreateOrUpdate(resourceGroupName string, c Chain: []validation.Constraint{{Target: "parameters.Properties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil}}}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, containerServiceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ContainerService + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, containerServiceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -112,7 +128,7 @@ func (client ContainerServicesClient) CreateOrUpdatePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-09-30" + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -137,13 +153,14 @@ func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (* // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerService, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -159,24 +176,37 @@ func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Respons // resourceGroupName is the name of the resource group. containerServiceName is // the name of the container service in the specified subscription and resource // group. -func (client ContainerServicesClient) Delete(resourceGroupName string, containerServiceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, containerServiceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure responding to request") - } - - return +func (client ContainerServicesClient) Delete(resourceGroupName string, containerServiceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, containerServiceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -187,7 +217,7 @@ func (client ContainerServicesClient) DeletePreparer(resourceGroupName string, c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-09-30" + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -231,13 +261,15 @@ func (client ContainerServicesClient) DeleteResponder(resp *http.Response) (resu func (client ContainerServicesClient) Get(resourceGroupName string, containerServiceName string) (result ContainerService, err error) { req, err := client.GetPreparer(resourceGroupName, containerServiceName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -256,7 +288,7 @@ func (client ContainerServicesClient) GetPreparer(resourceGroupName string, cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-09-30" + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -294,13 +326,15 @@ func (client ContainerServicesClient) GetResponder(resp *http.Response) (result func (client ContainerServicesClient) List() (result ListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -317,7 +351,7 @@ func (client ContainerServicesClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-09-30" + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -382,13 +416,15 @@ func (client ContainerServicesClient) ListNextResults(lastResults ListResult) (r func (client ContainerServicesClient) ListByResourceGroup(resourceGroupName string) (result ListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -406,7 +442,7 @@ func (client ContainerServicesClient) ListByResourceGroupPreparer(resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2016-09-30" + const APIVersion = "2017-01-31" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/arm/containerservice/version.go b/arm/containerservice/version.go index 47f91fc6a1f2..35892543e24c 100755 --- a/arm/containerservice/version.go +++ b/arm/containerservice/version.go @@ -20,10 +20,10 @@ package containerservice // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-containerservice/2016-09-30" + return "Azure-SDK-For-Go/v10.0.0-beta arm-containerservice/2017-01-31" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/customer-insights/authorizationpolicies.go b/arm/customer-insights/authorizationpolicies.go index 57cf46cf6c75..fb08c5a4d350 100644 --- a/arm/customer-insights/authorizationpolicies.go +++ b/arm/customer-insights/authorizationpolicies.go @@ -68,13 +68,15 @@ func (client AuthorizationPoliciesClient) CreateOrUpdate(resourceGroupName strin req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, authorizationPolicyName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -94,8 +96,9 @@ func (client AuthorizationPoliciesClient) CreateOrUpdatePreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -134,13 +137,15 @@ func (client AuthorizationPoliciesClient) CreateOrUpdateResponder(resp *http.Res func (client AuthorizationPoliciesClient) Get(resourceGroupName string, hubName string, authorizationPolicyName string) (result AuthorizationPolicyResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, authorizationPolicyName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -160,8 +165,9 @@ func (client AuthorizationPoliciesClient) GetPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -198,13 +204,15 @@ func (client AuthorizationPoliciesClient) GetResponder(resp *http.Response) (res func (client AuthorizationPoliciesClient) ListByHub(resourceGroupName string, hubName string) (result AuthorizationPolicyListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -223,8 +231,9 @@ func (client AuthorizationPoliciesClient) ListByHubPreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -286,13 +295,15 @@ func (client AuthorizationPoliciesClient) ListByHubNextResults(lastResults Autho func (client AuthorizationPoliciesClient) RegeneratePrimaryKey(resourceGroupName string, hubName string, authorizationPolicyName string) (result AuthorizationPolicy, err error) { req, err := client.RegeneratePrimaryKeyPreparer(resourceGroupName, hubName, authorizationPolicyName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + return } resp, err := client.RegeneratePrimaryKeySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegeneratePrimaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegeneratePrimaryKey", resp, "Failure sending request") + return } result, err = client.RegeneratePrimaryKeyResponder(resp) @@ -312,8 +323,9 @@ func (client AuthorizationPoliciesClient) RegeneratePrimaryKeyPreparer(resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -351,13 +363,15 @@ func (client AuthorizationPoliciesClient) RegeneratePrimaryKeyResponder(resp *ht func (client AuthorizationPoliciesClient) RegenerateSecondaryKey(resourceGroupName string, hubName string, authorizationPolicyName string) (result AuthorizationPolicy, err error) { req, err := client.RegenerateSecondaryKeyPreparer(resourceGroupName, hubName, authorizationPolicyName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + return } resp, err := client.RegenerateSecondaryKeySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegenerateSecondaryKey", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.AuthorizationPoliciesClient", "RegenerateSecondaryKey", resp, "Failure sending request") + return } result, err = client.RegenerateSecondaryKeyResponder(resp) @@ -377,8 +391,9 @@ func (client AuthorizationPoliciesClient) RegenerateSecondaryKeyPreparer(resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/client.go b/arm/customer-insights/client.go index be7dd066d0c7..7161204a7be8 100644 --- a/arm/customer-insights/client.go +++ b/arm/customer-insights/client.go @@ -30,9 +30,6 @@ import ( ) const ( - // APIVersion is the version of the Customerinsights - APIVersion = "2017-01-01" - // DefaultBaseURI is the default URI used for the service Customerinsights DefaultBaseURI = "https://management.azure.com" ) @@ -41,7 +38,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -55,7 +51,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/arm/customer-insights/connectormappings.go b/arm/customer-insights/connectormappings.go index 87872b305c85..fd13b7d699ad 100644 --- a/arm/customer-insights/connectormappings.go +++ b/arm/customer-insights/connectormappings.go @@ -77,13 +77,15 @@ func (client ConnectorMappingsClient) CreateOrUpdate(resourceGroupName string, h req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, connectorName, mappingName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -104,8 +106,9 @@ func (client ConnectorMappingsClient) CreateOrUpdatePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -145,13 +148,15 @@ func (client ConnectorMappingsClient) CreateOrUpdateResponder(resp *http.Respons func (client ConnectorMappingsClient) Delete(resourceGroupName string, hubName string, connectorName string, mappingName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, hubName, connectorName, mappingName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -172,8 +177,9 @@ func (client ConnectorMappingsClient) DeletePreparer(resourceGroupName string, h "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -210,13 +216,15 @@ func (client ConnectorMappingsClient) DeleteResponder(resp *http.Response) (resu func (client ConnectorMappingsClient) Get(resourceGroupName string, hubName string, connectorName string, mappingName string) (result ConnectorMappingResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, connectorName, mappingName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -237,8 +245,9 @@ func (client ConnectorMappingsClient) GetPreparer(resourceGroupName string, hubN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -275,13 +284,15 @@ func (client ConnectorMappingsClient) GetResponder(resp *http.Response) (result func (client ConnectorMappingsClient) ListByConnector(resourceGroupName string, hubName string, connectorName string) (result ConnectorMappingListResult, err error) { req, err := client.ListByConnectorPreparer(resourceGroupName, hubName, connectorName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "ListByConnector", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "ListByConnector", nil, "Failure preparing request") + return } resp, err := client.ListByConnectorSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "ListByConnector", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorMappingsClient", "ListByConnector", resp, "Failure sending request") + return } result, err = client.ListByConnectorResponder(resp) @@ -301,8 +312,9 @@ func (client ConnectorMappingsClient) ListByConnectorPreparer(resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/connectors.go b/arm/customer-insights/connectors.go index ab19509de65f..de3ff1d8209b 100644 --- a/arm/customer-insights/connectors.go +++ b/arm/customer-insights/connectors.go @@ -52,7 +52,9 @@ func NewConnectorsClientWithBaseURI(baseURI string, subscriptionID string) Conne // resourceGroupName is the name of the resource group. hubName is the name of // the hub. connectorName is the name of the connector. parameters is // parameters supplied to the CreateOrUpdate Connector operation. -func (client ConnectorsClient) CreateOrUpdate(resourceGroupName string, hubName string, connectorName string, parameters ConnectorResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ConnectorsClient) CreateOrUpdate(resourceGroupName string, hubName string, connectorName string, parameters ConnectorResourceFormat, cancel <-chan struct{}) (<-chan ConnectorResourceFormat, <-chan error) { + resultChan := make(chan ConnectorResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: connectorName, Constraints: []validation.Constraint{{Target: "connectorName", Name: validation.MaxLength, Rule: 128, Chain: nil}, @@ -61,26 +63,40 @@ func (client ConnectorsClient) CreateOrUpdate(resourceGroupName string, hubName {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Connector", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Connector.ConnectorProperties", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, connectorName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result ConnectorResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, connectorName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -92,8 +108,9 @@ func (client ConnectorsClient) CreateOrUpdatePreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -116,13 +133,14 @@ func (client ConnectorsClient) CreateOrUpdateSender(req *http.Request) (*http.Re // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ConnectorsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ConnectorsClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectorResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -132,24 +150,37 @@ func (client ConnectorsClient) CreateOrUpdateResponder(resp *http.Response) (res // // resourceGroupName is the name of the resource group. hubName is the name of // the hub. connectorName is the name of the connector. -func (client ConnectorsClient) Delete(resourceGroupName string, hubName string, connectorName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, hubName, connectorName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Delete", resp, "Failure responding to request") - } - - return +func (client ConnectorsClient) Delete(resourceGroupName string, hubName string, connectorName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, hubName, connectorName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -161,8 +192,9 @@ func (client ConnectorsClient) DeletePreparer(resourceGroupName string, hubName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -200,13 +232,15 @@ func (client ConnectorsClient) DeleteResponder(resp *http.Response) (result auto func (client ConnectorsClient) Get(resourceGroupName string, hubName string, connectorName string) (result ConnectorResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, connectorName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -226,8 +260,9 @@ func (client ConnectorsClient) GetPreparer(resourceGroupName string, hubName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -264,13 +299,15 @@ func (client ConnectorsClient) GetResponder(resp *http.Response) (result Connect func (client ConnectorsClient) ListByHub(resourceGroupName string, hubName string) (result ConnectorListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ConnectorsClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -289,8 +326,9 @@ func (client ConnectorsClient) ListByHubPreparer(resourceGroupName string, hubNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/hubs.go b/arm/customer-insights/hubs.go index e3bbee7eae15..42becee80d38 100644 --- a/arm/customer-insights/hubs.go +++ b/arm/customer-insights/hubs.go @@ -72,13 +72,15 @@ func (client HubsClient) CreateOrUpdate(resourceGroupName string, hubName string req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -97,8 +99,9 @@ func (client HubsClient) CreateOrUpdatePreparer(resourceGroupName string, hubNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -136,24 +139,37 @@ func (client HubsClient) CreateOrUpdateResponder(resp *http.Response) (result Hu // // resourceGroupName is the name of the resource group. hubName is the name of // the hub. -func (client HubsClient) Delete(resourceGroupName string, hubName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, hubName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Delete", resp, "Failure responding to request") - } - - return +func (client HubsClient) Delete(resourceGroupName string, hubName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, hubName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -164,8 +180,9 @@ func (client HubsClient) DeletePreparer(resourceGroupName string, hubName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -203,13 +220,15 @@ func (client HubsClient) DeleteResponder(resp *http.Response) (result autorest.R func (client HubsClient) Get(resourceGroupName string, hubName string) (result Hub, err error) { req, err := client.GetPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -228,8 +247,9 @@ func (client HubsClient) GetPreparer(resourceGroupName string, hubName string) ( "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -263,13 +283,15 @@ func (client HubsClient) GetResponder(resp *http.Response) (result Hub, err erro func (client HubsClient) List() (result HubListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -286,8 +308,9 @@ func (client HubsClient) ListPreparer() (*http.Request, error) { "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -347,13 +370,15 @@ func (client HubsClient) ListNextResults(lastResults HubListResult) (result HubL func (client HubsClient) ListByResourceGroup(resourceGroupName string) (result HubListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -371,8 +396,9 @@ func (client HubsClient) ListByResourceGroupPreparer(resourceGroupName string) ( "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -433,13 +459,15 @@ func (client HubsClient) ListByResourceGroupNextResults(lastResults HubListResul func (client HubsClient) Update(resourceGroupName string, hubName string, parameters Hub) (result Hub, err error) { req, err := client.UpdatePreparer(resourceGroupName, hubName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.HubsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -458,8 +486,9 @@ func (client HubsClient) UpdatePreparer(resourceGroupName string, hubName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/images.go b/arm/customer-insights/images.go index f6ec06d0bdf9..c77ace5a9b43 100644 --- a/arm/customer-insights/images.go +++ b/arm/customer-insights/images.go @@ -50,13 +50,15 @@ func NewImagesClientWithBaseURI(baseURI string, subscriptionID string) ImagesCli func (client ImagesClient) GetUploadURLForData(resourceGroupName string, hubName string, parameters GetImageUploadURLInput) (result ImageDefinition, err error) { req, err := client.GetUploadURLForDataPreparer(resourceGroupName, hubName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForData", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForData", nil, "Failure preparing request") + return } resp, err := client.GetUploadURLForDataSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForData", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForData", resp, "Failure sending request") + return } result, err = client.GetUploadURLForDataResponder(resp) @@ -75,8 +77,9 @@ func (client ImagesClient) GetUploadURLForDataPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -117,13 +120,15 @@ func (client ImagesClient) GetUploadURLForDataResponder(resp *http.Response) (re func (client ImagesClient) GetUploadURLForEntityType(resourceGroupName string, hubName string, parameters GetImageUploadURLInput) (result ImageDefinition, err error) { req, err := client.GetUploadURLForEntityTypePreparer(resourceGroupName, hubName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForEntityType", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForEntityType", nil, "Failure preparing request") + return } resp, err := client.GetUploadURLForEntityTypeSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForEntityType", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ImagesClient", "GetUploadURLForEntityType", resp, "Failure sending request") + return } result, err = client.GetUploadURLForEntityTypeResponder(resp) @@ -142,8 +147,9 @@ func (client ImagesClient) GetUploadURLForEntityTypePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/interactions.go b/arm/customer-insights/interactions.go index 2581a6f44268..1999cf078b1e 100644 --- a/arm/customer-insights/interactions.go +++ b/arm/customer-insights/interactions.go @@ -53,32 +53,48 @@ func NewInteractionsClientWithBaseURI(baseURI string, subscriptionID string) Int // resourceGroupName is the name of the resource group. hubName is the name of // the hub. interactionName is the name of the interaction. parameters is // parameters supplied to the CreateOrUpdate Interaction operation. -func (client InteractionsClient) CreateOrUpdate(resourceGroupName string, hubName string, interactionName string, parameters InteractionResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client InteractionsClient) CreateOrUpdate(resourceGroupName string, hubName string, interactionName string, parameters InteractionResourceFormat, cancel <-chan struct{}) (<-chan InteractionResourceFormat, <-chan error) { + resultChan := make(chan InteractionResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: interactionName, Constraints: []validation.Constraint{{Target: "interactionName", Name: validation.MaxLength, Rule: 128, Chain: nil}, {Target: "interactionName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "interactionName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9_]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.InteractionsClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.InteractionsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, interactionName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result InteractionResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, interactionName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -90,8 +106,9 @@ func (client InteractionsClient) CreateOrUpdatePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,13 +131,14 @@ func (client InteractionsClient) CreateOrUpdateSender(req *http.Request) (*http. // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client InteractionsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client InteractionsClient) CreateOrUpdateResponder(resp *http.Response) (result InteractionResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -132,13 +150,15 @@ func (client InteractionsClient) CreateOrUpdateResponder(resp *http.Response) (r func (client InteractionsClient) Get(resourceGroupName string, hubName string, interactionName string, localeCode string) (result InteractionResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, interactionName, localeCode) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -158,8 +178,9 @@ func (client InteractionsClient) GetPreparer(resourceGroupName string, hubName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(localeCode) > 0 { queryParameters["locale-code"] = autorest.Encode("query", localeCode) @@ -199,13 +220,15 @@ func (client InteractionsClient) GetResponder(resp *http.Response) (result Inter func (client InteractionsClient) ListByHub(resourceGroupName string, hubName string, localeCode string) (result InteractionListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName, localeCode) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -224,8 +247,9 @@ func (client InteractionsClient) ListByHubPreparer(resourceGroupName string, hub "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(localeCode) > 0 { queryParameters["locale-code"] = autorest.Encode("query", localeCode) @@ -281,3 +305,71 @@ func (client InteractionsClient) ListByHubNextResults(lastResults InteractionLis return } + +// SuggestRelationshipLinks suggests relationships to create relationship +// links. +// +// resourceGroupName is the name of the resource group. hubName is the name of +// the hub. interactionName is the name of the interaction. +func (client InteractionsClient) SuggestRelationshipLinks(resourceGroupName string, hubName string, interactionName string) (result SuggestRelationshipLinksResponse, err error) { + req, err := client.SuggestRelationshipLinksPreparer(resourceGroupName, hubName, interactionName) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "SuggestRelationshipLinks", nil, "Failure preparing request") + return + } + + resp, err := client.SuggestRelationshipLinksSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "SuggestRelationshipLinks", resp, "Failure sending request") + return + } + + result, err = client.SuggestRelationshipLinksResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.InteractionsClient", "SuggestRelationshipLinks", resp, "Failure responding to request") + } + + return +} + +// SuggestRelationshipLinksPreparer prepares the SuggestRelationshipLinks request. +func (client InteractionsClient) SuggestRelationshipLinksPreparer(resourceGroupName string, hubName string, interactionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hubName": autorest.Encode("path", hubName), + "interactionName": autorest.Encode("path", interactionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/interactions/{interactionName}/suggestRelationshipLinks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// SuggestRelationshipLinksSender sends the SuggestRelationshipLinks request. The method will close the +// http.Response Body if it receives an error. +func (client InteractionsClient) SuggestRelationshipLinksSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// SuggestRelationshipLinksResponder handles the response to the SuggestRelationshipLinks request. The method always +// closes the http.Response Body. +func (client InteractionsClient) SuggestRelationshipLinksResponder(resp *http.Response) (result SuggestRelationshipLinksResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/customer-insights/kpi.go b/arm/customer-insights/kpi.go index 16d692d0e944..7110ba1984e1 100644 --- a/arm/customer-insights/kpi.go +++ b/arm/customer-insights/kpi.go @@ -51,7 +51,9 @@ func NewKpiClientWithBaseURI(baseURI string, subscriptionID string) KpiClient { // resourceGroupName is the name of the resource group. hubName is the name of // the hub. kpiName is the name of the KPI. parameters is parameters supplied // to the create/update KPI operation. -func (client KpiClient) CreateOrUpdate(resourceGroupName string, hubName string, kpiName string, parameters KpiResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client KpiClient) CreateOrUpdate(resourceGroupName string, hubName string, kpiName string, parameters KpiResourceFormat, cancel <-chan struct{}) (<-chan KpiResourceFormat, <-chan error) { + resultChan := make(chan KpiResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: kpiName, Constraints: []validation.Constraint{{Target: "kpiName", Name: validation.MaxLength, Rule: 512, Chain: nil}, @@ -67,26 +69,40 @@ func (client KpiClient) CreateOrUpdate(resourceGroupName string, hubName string, {Target: "parameters.KpiDefinition.ThresHolds.IncreasingKpi", Name: validation.Null, Rule: true, Chain: nil}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.KpiClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.KpiClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, kpiName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result KpiResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, kpiName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -98,8 +114,9 @@ func (client KpiClient) CreateOrUpdatePreparer(resourceGroupName string, hubName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -122,13 +139,14 @@ func (client KpiClient) CreateOrUpdateSender(req *http.Request) (*http.Response, // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client KpiClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client KpiClient) CreateOrUpdateResponder(resp *http.Response) (result KpiResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -138,24 +156,37 @@ func (client KpiClient) CreateOrUpdateResponder(resp *http.Response) (result aut // // resourceGroupName is the name of the resource group. hubName is the name of // the hub. kpiName is the name of the KPI. -func (client KpiClient) Delete(resourceGroupName string, hubName string, kpiName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, hubName, kpiName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Delete", resp, "Failure responding to request") - } - - return +func (client KpiClient) Delete(resourceGroupName string, hubName string, kpiName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, hubName, kpiName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -167,8 +198,9 @@ func (client KpiClient) DeletePreparer(resourceGroupName string, hubName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -206,13 +238,15 @@ func (client KpiClient) DeleteResponder(resp *http.Response) (result autorest.Re func (client KpiClient) Get(resourceGroupName string, hubName string, kpiName string) (result KpiResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, kpiName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -232,8 +266,9 @@ func (client KpiClient) GetPreparer(resourceGroupName string, hubName string, kp "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -270,13 +305,15 @@ func (client KpiClient) GetResponder(resp *http.Response) (result KpiResourceFor func (client KpiClient) ListByHub(resourceGroupName string, hubName string) (result KpiListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -295,8 +332,9 @@ func (client KpiClient) ListByHubPreparer(resourceGroupName string, hubName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -357,13 +395,15 @@ func (client KpiClient) ListByHubNextResults(lastResults KpiListResult) (result func (client KpiClient) Reprocess(resourceGroupName string, hubName string, kpiName string) (result autorest.Response, err error) { req, err := client.ReprocessPreparer(resourceGroupName, hubName, kpiName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Reprocess", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Reprocess", nil, "Failure preparing request") + return } resp, err := client.ReprocessSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Reprocess", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.KpiClient", "Reprocess", resp, "Failure sending request") + return } result, err = client.ReprocessResponder(resp) @@ -383,8 +423,9 @@ func (client KpiClient) ReprocessPreparer(resourceGroupName string, hubName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/links.go b/arm/customer-insights/links.go index 39e47b3e2346..dcae7fcd1428 100644 --- a/arm/customer-insights/links.go +++ b/arm/customer-insights/links.go @@ -51,7 +51,9 @@ func NewLinksClientWithBaseURI(baseURI string, subscriptionID string) LinksClien // resourceGroupName is the name of the resource group. hubName is the name of // the hub. linkName is the name of the link. parameters is parameters supplied // to the CreateOrUpdate Link operation. -func (client LinksClient) CreateOrUpdate(resourceGroupName string, hubName string, linkName string, parameters LinkResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client LinksClient) CreateOrUpdate(resourceGroupName string, hubName string, linkName string, parameters LinkResourceFormat, cancel <-chan struct{}) (<-chan LinkResourceFormat, <-chan error) { + resultChan := make(chan LinkResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: linkName, Constraints: []validation.Constraint{{Target: "linkName", Name: validation.MaxLength, Rule: 512, Chain: nil}, @@ -63,26 +65,40 @@ func (client LinksClient) CreateOrUpdate(resourceGroupName string, hubName strin {Target: "parameters.LinkDefinition.TargetProfileType", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.LinkDefinition.ParticipantPropertyReferences", Name: validation.Null, Rule: true, Chain: nil}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.LinksClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.LinksClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, linkName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result LinkResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, linkName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -94,8 +110,9 @@ func (client LinksClient) CreateOrUpdatePreparer(resourceGroupName string, hubNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -118,13 +135,14 @@ func (client LinksClient) CreateOrUpdateSender(req *http.Request) (*http.Respons // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client LinksClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client LinksClient) CreateOrUpdateResponder(resp *http.Response) (result LinkResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -135,13 +153,15 @@ func (client LinksClient) CreateOrUpdateResponder(resp *http.Response) (result a func (client LinksClient) Delete(resourceGroupName string, hubName string, linkName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, hubName, linkName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -161,8 +181,9 @@ func (client LinksClient) DeletePreparer(resourceGroupName string, hubName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -198,13 +219,15 @@ func (client LinksClient) DeleteResponder(resp *http.Response) (result autorest. func (client LinksClient) Get(resourceGroupName string, hubName string, linkName string) (result LinkResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, linkName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -224,8 +247,9 @@ func (client LinksClient) GetPreparer(resourceGroupName string, hubName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -262,13 +286,15 @@ func (client LinksClient) GetResponder(resp *http.Response) (result LinkResource func (client LinksClient) ListByHub(resourceGroupName string, hubName string) (result LinkListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.LinksClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.LinksClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -287,8 +313,9 @@ func (client LinksClient) ListByHubPreparer(resourceGroupName string, hubName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/models.go b/arm/customer-insights/models.go index 6ab25af3efa2..8458d73cc30e 100644 --- a/arm/customer-insights/models.go +++ b/arm/customer-insights/models.go @@ -34,6 +34,8 @@ const ( Day CalculationWindowTypes = "Day" // Hour specifies the hour state for calculation window types. Hour CalculationWindowTypes = "Hour" + // Lifetime specifies the lifetime state for calculation window types. + Lifetime CalculationWindowTypes = "Lifetime" // Month specifies the month state for calculation window types. Month CalculationWindowTypes = "Month" // Week specifies the week state for calculation window types. @@ -118,22 +120,46 @@ const ( AzureBlob ConnectorTypes = "AzureBlob" // CRM specifies the crm state for connector types. CRM ConnectorTypes = "CRM" + // ExchangeOnline specifies the exchange online state for connector types. + ExchangeOnline ConnectorTypes = "ExchangeOnline" + // None specifies the none state for connector types. + None ConnectorTypes = "None" + // Outbound specifies the outbound state for connector types. + Outbound ConnectorTypes = "Outbound" // Salesforce specifies the salesforce state for connector types. Salesforce ConnectorTypes = "Salesforce" ) +// DataSourceType enumerates the values for data source type. +type DataSourceType string + +const ( + // DataSourceTypeConnectorMapping specifies the data source type connector + // mapping state for data source type. + DataSourceTypeConnectorMapping DataSourceType = "ConnectorMapping" + // DataSourceTypeLinkInteraction specifies the data source type link + // interaction state for data source type. + DataSourceTypeLinkInteraction DataSourceType = "LinkInteraction" + // DataSourceTypeSystemDefault specifies the data source type system + // default state for data source type. + DataSourceTypeSystemDefault DataSourceType = "SystemDefault" +) + // EntityTypes enumerates the values for entity types. type EntityTypes string const ( - // Interaction specifies the interaction state for entity types. - Interaction EntityTypes = "Interaction" - // None specifies the none state for entity types. - None EntityTypes = "None" - // Profile specifies the profile state for entity types. - Profile EntityTypes = "Profile" - // Relationship specifies the relationship state for entity types. - Relationship EntityTypes = "Relationship" + // EntityTypesInteraction specifies the entity types interaction state for + // entity types. + EntityTypesInteraction EntityTypes = "Interaction" + // EntityTypesNone specifies the entity types none state for entity types. + EntityTypesNone EntityTypes = "None" + // EntityTypesProfile specifies the entity types profile state for entity + // types. + EntityTypesProfile EntityTypes = "Profile" + // EntityTypesRelationship specifies the entity types relationship state + // for entity types. + EntityTypesRelationship EntityTypes = "Relationship" ) // ErrorManagementTypes enumerates the values for error management types. @@ -171,6 +197,16 @@ const ( FrequencyTypesWeek FrequencyTypes = "Week" ) +// InstanceOperationType enumerates the values for instance operation type. +type InstanceOperationType string + +const ( + // Delete specifies the delete state for instance operation type. + Delete InstanceOperationType = "Delete" + // Upsert specifies the upsert state for instance operation type. + Upsert InstanceOperationType = "Upsert" +) + // KpiFunctions enumerates the values for kpi functions. type KpiFunctions string @@ -180,6 +216,9 @@ const ( // KpiFunctionsCount specifies the kpi functions count state for kpi // functions. KpiFunctionsCount KpiFunctions = "Count" + // KpiFunctionsCountDistinct specifies the kpi functions count distinct + // state for kpi functions. + KpiFunctionsCountDistinct KpiFunctions = "CountDistinct" // KpiFunctionsLast specifies the kpi functions last state for kpi // functions. KpiFunctionsLast KpiFunctions = "Last" @@ -220,9 +259,18 @@ const ( type ProvisioningStates string const ( + // ProvisioningStatesDeleting specifies the provisioning states deleting + // state for provisioning states. + ProvisioningStatesDeleting ProvisioningStates = "Deleting" + // ProvisioningStatesExpiring specifies the provisioning states expiring + // state for provisioning states. + ProvisioningStatesExpiring ProvisioningStates = "Expiring" // ProvisioningStatesFailed specifies the provisioning states failed state // for provisioning states. ProvisioningStatesFailed ProvisioningStates = "Failed" + // ProvisioningStatesHumanIntervention specifies the provisioning states + // human intervention state for provisioning states. + ProvisioningStatesHumanIntervention ProvisioningStates = "HumanIntervention" // ProvisioningStatesProvisioning specifies the provisioning states // provisioning state for provisioning states. ProvisioningStatesProvisioning ProvisioningStates = "Provisioning" @@ -312,6 +360,7 @@ type Connector struct { LastModified *date.Time `json:"lastModified,omitempty"` State ConnectorStates `json:"state,omitempty"` TenantID *string `json:"tenantId,omitempty"` + IsInternal *bool `json:"isInternal,omitempty"` } // ConnectorListResult is the response of list connector operation. @@ -454,6 +503,39 @@ type CrmConnectorProperties struct { AccessToken *string `json:"accessToken,omitempty"` } +// DataSource is data Source is a way for us to know the source of instances. A +// single type can have data coming in from multiple places. In activities we +// use this to determine precedence rules. +type DataSource struct { + DataSourceType DataSourceType `json:"dataSourceType,omitempty"` + ID *string `json:"id,omitempty"` + LinkID *string `json:"linkId,omitempty"` + ConnectorMappingID *string `json:"connectorMappingId,omitempty"` +} + +// EnrichingKpi is the enriching KPI definition. +type EnrichingKpi struct { + EntityType EntityTypes `json:"entityType,omitempty"` + EntityTypeName *string `json:"entityTypeName,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + KpiName *string `json:"kpiName,omitempty"` + DisplayName *map[string]*string `json:"displayName,omitempty"` + Description *map[string]*string `json:"description,omitempty"` + CalculationWindow CalculationWindowTypes `json:"calculationWindow,omitempty"` + CalculationWindowFieldName *string `json:"calculationWindowFieldName,omitempty"` + Function KpiFunctions `json:"function,omitempty"` + Expression *string `json:"expression,omitempty"` + Unit *string `json:"unit,omitempty"` + Filter *string `json:"filter,omitempty"` + GroupBy *[]string `json:"groupBy,omitempty"` + GroupByMetadata *[]KpiGroupByMetadata `json:"groupByMetadata,omitempty"` + ParticipantProfilesMetadata *[]KpiParticipantProfilesMetadata `json:"participantProfilesMetadata,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` + ThresHolds *KpiThresholds `json:"thresHolds,omitempty"` + Aliases *[]KpiAlias `json:"aliases,omitempty"` + Extracts *[]KpiExtract `json:"extracts,omitempty"` +} + // EntityTypeDefinition is describes an entity. type EntityTypeDefinition struct { Attributes *map[string][]string `json:"attributes,omitempty"` @@ -468,7 +550,7 @@ type EntityTypeDefinition struct { Fields *[]PropertyDefinition `json:"fields,omitempty"` InstancesCount *int32 `json:"instancesCount,omitempty"` LastChangedUtc *date.Time `json:"lastChangedUtc,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` SchemaItemTypeLink *string `json:"schemaItemTypeLink,omitempty"` TenantID *string `json:"tenantId,omitempty"` TimestampFieldName *string `json:"timestampFieldName,omitempty"` @@ -578,7 +660,7 @@ type InteractionTypeDefinition struct { Fields *[]PropertyDefinition `json:"fields,omitempty"` InstancesCount *int32 `json:"instancesCount,omitempty"` LastChangedUtc *date.Time `json:"lastChangedUtc,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` SchemaItemTypeLink *string `json:"schemaItemTypeLink,omitempty"` TenantID *string `json:"tenantId,omitempty"` TimestampFieldName *string `json:"timestampFieldName,omitempty"` @@ -586,6 +668,9 @@ type InteractionTypeDefinition struct { IDPropertyNames *[]string `json:"idPropertyNames,omitempty"` ParticipantProfiles *[]Participant `json:"participantProfiles,omitempty"` PrimaryParticipantProfilePropertyName *string `json:"primaryParticipantProfilePropertyName,omitempty"` + DataSources *[]DataSource `json:"dataSources,omitempty"` + DefaultDataSourceID *string `json:"defaultDataSourceId,omitempty"` + IsActivity *bool `json:"isActivity,omitempty"` } // KpiAlias is the KPI alias. @@ -603,6 +688,7 @@ type KpiDefinition struct { DisplayName *map[string]*string `json:"displayName,omitempty"` Description *map[string]*string `json:"description,omitempty"` CalculationWindow CalculationWindowTypes `json:"calculationWindow,omitempty"` + CalculationWindowFieldName *string `json:"calculationWindowFieldName,omitempty"` Function KpiFunctions `json:"function,omitempty"` Expression *string `json:"expression,omitempty"` Unit *string `json:"unit,omitempty"` @@ -610,7 +696,7 @@ type KpiDefinition struct { GroupBy *[]string `json:"groupBy,omitempty"` GroupByMetadata *[]KpiGroupByMetadata `json:"groupByMetadata,omitempty"` ParticipantProfilesMetadata *[]KpiParticipantProfilesMetadata `json:"participantProfilesMetadata,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` ThresHolds *KpiThresholds `json:"thresHolds,omitempty"` Aliases *[]KpiAlias `json:"aliases,omitempty"` Extracts *[]KpiExtract `json:"extracts,omitempty"` @@ -679,8 +765,9 @@ type LinkDefinition struct { Description *map[string]*string `json:"description,omitempty"` Mappings *[]TypePropertiesMapping `json:"mappings,omitempty"` ParticipantPropertyReferences *[]ParticipantPropertyReference `json:"participantPropertyReferences,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` ReferenceOnly *bool `json:"referenceOnly,omitempty"` + OperationType InstanceOperationType `json:"operationType,omitempty"` } // LinkListResult is the response of list link operation. @@ -711,6 +798,12 @@ type LinkResourceFormat struct { *LinkDefinition `json:"properties,omitempty"` } +// ListKpiDefinition is +type ListKpiDefinition struct { + autorest.Response `json:"-"` + Value *[]KpiDefinition `json:"value,omitempty"` +} + // MetadataDefinitionBase is the Metadata definition base. type MetadataDefinitionBase struct { Attributes *map[string][]string `json:"attributes,omitempty"` @@ -787,7 +880,7 @@ type ProfileTypeDefinition struct { Fields *[]PropertyDefinition `json:"fields,omitempty"` InstancesCount *int32 `json:"instancesCount,omitempty"` LastChangedUtc *date.Time `json:"lastChangedUtc,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` SchemaItemTypeLink *string `json:"schemaItemTypeLink,omitempty"` TenantID *string `json:"tenantId,omitempty"` TimestampFieldName *string `json:"timestampFieldName,omitempty"` @@ -810,6 +903,8 @@ type PropertyDefinition struct { IsRequired *bool `json:"isRequired,omitempty"` PropertyID *string `json:"propertyId,omitempty"` SchemaItemPropLink *string `json:"schemaItemPropLink,omitempty"` + MaxLength *int32 `json:"maxLength,omitempty"` + IsAvailableInGraph *bool `json:"isAvailableInGraph,omitempty"` } // ProxyResource is common properties of proxy resource. @@ -828,7 +923,7 @@ type RelationshipDefinition struct { Fields *[]PropertyDefinition `json:"fields,omitempty"` LookupMappings *[]RelationshipTypeMapping `json:"lookupMappings,omitempty"` ProfileType *string `json:"profileType,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` RelationshipName *string `json:"relationshipName,omitempty"` RelatedProfileType *string `json:"relatedProfileType,omitempty"` RelationshipGUIDID *string `json:"relationshipGuidId,omitempty"` @@ -843,7 +938,7 @@ type RelationshipLinkDefinition struct { LinkName *string `json:"linkName,omitempty"` Mappings *[]RelationshipLinkFieldMapping `json:"mappings,omitempty"` ProfilePropertyReferences *[]ParticipantPropertyReference `json:"profilePropertyReferences,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` RelatedProfilePropertyReferences *[]ParticipantPropertyReference `json:"relatedProfilePropertyReferences,omitempty"` RelationshipName *string `json:"relationshipName,omitempty"` RelationshipGUIDID *string `json:"relationshipGuidId,omitempty"` @@ -914,6 +1009,16 @@ type RelationshipResourceFormat struct { *RelationshipDefinition `json:"properties,omitempty"` } +// RelationshipsLookup is the definition of suggested relationship for the +// type. +type RelationshipsLookup struct { + ProfileName *string `json:"profileName,omitempty"` + ProfilePropertyReferences *[]ParticipantPropertyReference `json:"profilePropertyReferences,omitempty"` + RelatedProfileName *string `json:"relatedProfileName,omitempty"` + RelatedProfilePropertyReferences *[]ParticipantPropertyReference `json:"relatedProfilePropertyReferences,omitempty"` + ExistingRelationshipName *string `json:"existingRelationshipName,omitempty"` +} + // RelationshipTypeFieldMapping is map a field of profile to its corresponding // StrongId in Related Profile. type RelationshipTypeFieldMapping struct { @@ -950,24 +1055,26 @@ type Role struct { // RoleAssignment is the Role Assignment definition. type RoleAssignment struct { - TenantID *string `json:"tenantId,omitempty"` - AssignmentName *string `json:"assignmentName,omitempty"` - DisplayName *map[string]*string `json:"displayName,omitempty"` - Description *map[string]*string `json:"description,omitempty"` - ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` - Role RoleTypes `json:"role,omitempty"` - Principals *[]AssignmentPrincipal `json:"principals,omitempty"` - Profiles *ResourceSetDescription `json:"profiles,omitempty"` - Interactions *ResourceSetDescription `json:"interactions,omitempty"` - Links *ResourceSetDescription `json:"links,omitempty"` - Kpis *ResourceSetDescription `json:"kpis,omitempty"` - SasPolicies *ResourceSetDescription `json:"sasPolicies,omitempty"` - Connectors *ResourceSetDescription `json:"connectors,omitempty"` - Views *ResourceSetDescription `json:"views,omitempty"` - RelationshipLinks *ResourceSetDescription `json:"relationshipLinks,omitempty"` - Relationships *ResourceSetDescription `json:"relationships,omitempty"` - WidgetTypes *ResourceSetDescription `json:"widgetTypes,omitempty"` - RoleAssignments *ResourceSetDescription `json:"roleAssignments,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + AssignmentName *string `json:"assignmentName,omitempty"` + DisplayName *map[string]*string `json:"displayName,omitempty"` + Description *map[string]*string `json:"description,omitempty"` + ProvisioningState ProvisioningStates `json:"provisioningState,omitempty"` + Role RoleTypes `json:"role,omitempty"` + Principals *[]AssignmentPrincipal `json:"principals,omitempty"` + Profiles *ResourceSetDescription `json:"profiles,omitempty"` + Interactions *ResourceSetDescription `json:"interactions,omitempty"` + Links *ResourceSetDescription `json:"links,omitempty"` + Kpis *ResourceSetDescription `json:"kpis,omitempty"` + SasPolicies *ResourceSetDescription `json:"sasPolicies,omitempty"` + Connectors *ResourceSetDescription `json:"connectors,omitempty"` + Views *ResourceSetDescription `json:"views,omitempty"` + RelationshipLinks *ResourceSetDescription `json:"relationshipLinks,omitempty"` + Relationships *ResourceSetDescription `json:"relationships,omitempty"` + WidgetTypes *ResourceSetDescription `json:"widgetTypes,omitempty"` + RoleAssignments *ResourceSetDescription `json:"roleAssignments,omitempty"` + ConflationPolicies *ResourceSetDescription `json:"conflationPolicies,omitempty"` + Segments *ResourceSetDescription `json:"segments,omitempty"` } // RoleAssignmentListResult is the response of list role assignment operation. @@ -1053,6 +1160,14 @@ type StrongID struct { Description *map[string]*string `json:"description,omitempty"` } +// SuggestRelationshipLinksResponse is the response of suggest relationship +// links operation. +type SuggestRelationshipLinksResponse struct { + autorest.Response `json:"-"` + InteractionName *string `json:"interactionName,omitempty"` + SuggestedRelationships *[]RelationshipsLookup `json:"suggestedRelationships,omitempty"` +} + // TypePropertiesMapping is metadata for a Link's property mapping. type TypePropertiesMapping struct { InteractionTypePropertyName *string `json:"interactionTypePropertyName,omitempty"` diff --git a/arm/customer-insights/profiles.go b/arm/customer-insights/profiles.go index 7596451465e9..c323e8179ee3 100644 --- a/arm/customer-insights/profiles.go +++ b/arm/customer-insights/profiles.go @@ -52,32 +52,48 @@ func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) Profile // resourceGroupName is the name of the resource group. hubName is the name of // the hub. profileName is the name of the profile. parameters is parameters // supplied to the create/delete Profile type operation -func (client ProfilesClient) CreateOrUpdate(resourceGroupName string, hubName string, profileName string, parameters ProfileResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ProfilesClient) CreateOrUpdate(resourceGroupName string, hubName string, profileName string, parameters ProfileResourceFormat, cancel <-chan struct{}) (<-chan ProfileResourceFormat, <-chan error) { + resultChan := make(chan ProfileResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: profileName, Constraints: []validation.Constraint{{Target: "profileName", Name: validation.MaxLength, Rule: 128, Chain: nil}, {Target: "profileName", Name: validation.MinLength, Rule: 1, Chain: nil}, {Target: "profileName", Name: validation.Pattern, Rule: `^[a-zA-Z][a-zA-Z0-9_]+$`, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.ProfilesClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.ProfilesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, profileName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result ProfileResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, profileName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -89,8 +105,9 @@ func (client ProfilesClient) CreateOrUpdatePreparer(resourceGroupName string, hu "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -113,13 +130,14 @@ func (client ProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Resp // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result ProfileResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -130,24 +148,37 @@ func (client ProfilesClient) CreateOrUpdateResponder(resp *http.Response) (resul // resourceGroupName is the name of the resource group. hubName is the name of // the hub. profileName is the name of the profile. localeCode is locale of // profile to retrieve, default is en-us. -func (client ProfilesClient) Delete(resourceGroupName string, hubName string, profileName string, localeCode string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, hubName, profileName, localeCode, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Delete", resp, "Failure responding to request") - } - - return +func (client ProfilesClient) Delete(resourceGroupName string, hubName string, profileName string, localeCode string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, hubName, profileName, localeCode, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -159,8 +190,9 @@ func (client ProfilesClient) DeletePreparer(resourceGroupName string, hubName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(localeCode) > 0 { queryParameters["locale-code"] = autorest.Encode("query", localeCode) @@ -202,13 +234,15 @@ func (client ProfilesClient) DeleteResponder(resp *http.Response) (result autore func (client ProfilesClient) Get(resourceGroupName string, hubName string, profileName string, localeCode string) (result ProfileResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, profileName, localeCode) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -228,8 +262,9 @@ func (client ProfilesClient) GetPreparer(resourceGroupName string, hubName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(localeCode) > 0 { queryParameters["locale-code"] = autorest.Encode("query", localeCode) @@ -262,6 +297,76 @@ func (client ProfilesClient) GetResponder(resp *http.Response) (result ProfileRe return } +// GetEnrichingKpis gets the KPIs that enrich the profile Type identified by +// the supplied name. Enrichment happens through participants of the +// Interaction on an Interaction KPI and through Relationships for Profile +// KPIs. +// +// resourceGroupName is the name of the resource group. hubName is the name of +// the hub. profileName is the name of the profile. +func (client ProfilesClient) GetEnrichingKpis(resourceGroupName string, hubName string, profileName string) (result ListKpiDefinition, err error) { + req, err := client.GetEnrichingKpisPreparer(resourceGroupName, hubName, profileName) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "GetEnrichingKpis", nil, "Failure preparing request") + return + } + + resp, err := client.GetEnrichingKpisSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "GetEnrichingKpis", resp, "Failure sending request") + return + } + + result, err = client.GetEnrichingKpisResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "GetEnrichingKpis", resp, "Failure responding to request") + } + + return +} + +// GetEnrichingKpisPreparer prepares the GetEnrichingKpis request. +func (client ProfilesClient) GetEnrichingKpisPreparer(resourceGroupName string, hubName string, profileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hubName": autorest.Encode("path", hubName), + "profileName": autorest.Encode("path", profileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/profiles/{profileName}/getEnrichingKpis", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetEnrichingKpisSender sends the GetEnrichingKpis request. The method will close the +// http.Response Body if it receives an error. +func (client ProfilesClient) GetEnrichingKpisSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetEnrichingKpisResponder handles the response to the GetEnrichingKpis request. The method always +// closes the http.Response Body. +func (client ProfilesClient) GetEnrichingKpisResponder(resp *http.Response) (result ListKpiDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByHub gets all profile in the hub. // // resourceGroupName is the name of the resource group. hubName is the name of @@ -269,13 +374,15 @@ func (client ProfilesClient) GetResponder(resp *http.Response) (result ProfileRe func (client ProfilesClient) ListByHub(resourceGroupName string, hubName string, localeCode string) (result ProfileListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName, localeCode) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ProfilesClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -294,8 +401,9 @@ func (client ProfilesClient) ListByHubPreparer(resourceGroupName string, hubName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(localeCode) > 0 { queryParameters["locale-code"] = autorest.Encode("query", localeCode) diff --git a/arm/customer-insights/relationshiplinks.go b/arm/customer-insights/relationshiplinks.go index 95509200695a..6cac63649f30 100644 --- a/arm/customer-insights/relationshiplinks.go +++ b/arm/customer-insights/relationshiplinks.go @@ -55,7 +55,9 @@ func NewRelationshipLinksClientWithBaseURI(baseURI string, subscriptionID string // the hub. relationshipLinkName is the name of the relationship link. // parameters is parameters supplied to the CreateOrUpdate relationship link // operation. -func (client RelationshipLinksClient) CreateOrUpdate(resourceGroupName string, hubName string, relationshipLinkName string, parameters RelationshipLinkResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client RelationshipLinksClient) CreateOrUpdate(resourceGroupName string, hubName string, relationshipLinkName string, parameters RelationshipLinkResourceFormat, cancel <-chan struct{}) (<-chan RelationshipLinkResourceFormat, <-chan error) { + resultChan := make(chan RelationshipLinkResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: relationshipLinkName, Constraints: []validation.Constraint{{Target: "relationshipLinkName", Name: validation.MaxLength, Rule: 512, Chain: nil}, @@ -68,26 +70,40 @@ func (client RelationshipLinksClient) CreateOrUpdate(resourceGroupName string, h {Target: "parameters.RelationshipLinkDefinition.RelatedProfilePropertyReferences", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.RelationshipLinkDefinition.RelationshipName", Name: validation.Null, Rule: true, Chain: nil}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, relationshipLinkName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result RelationshipLinkResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, relationshipLinkName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -99,8 +115,9 @@ func (client RelationshipLinksClient) CreateOrUpdatePreparer(resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -123,13 +140,14 @@ func (client RelationshipLinksClient) CreateOrUpdateSender(req *http.Request) (* // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client RelationshipLinksClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client RelationshipLinksClient) CreateOrUpdateResponder(resp *http.Response) (result RelationshipLinkResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -140,24 +158,37 @@ func (client RelationshipLinksClient) CreateOrUpdateResponder(resp *http.Respons // // resourceGroupName is the name of the resource group. hubName is the name of // the hub. relationshipLinkName is the name of the relationship. -func (client RelationshipLinksClient) Delete(resourceGroupName string, hubName string, relationshipLinkName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, hubName, relationshipLinkName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Delete", resp, "Failure responding to request") - } - - return +func (client RelationshipLinksClient) Delete(resourceGroupName string, hubName string, relationshipLinkName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, hubName, relationshipLinkName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -169,8 +200,9 @@ func (client RelationshipLinksClient) DeletePreparer(resourceGroupName string, h "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -208,13 +240,15 @@ func (client RelationshipLinksClient) DeleteResponder(resp *http.Response) (resu func (client RelationshipLinksClient) Get(resourceGroupName string, hubName string, relationshipLinkName string) (result RelationshipLinkResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, relationshipLinkName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -234,8 +268,9 @@ func (client RelationshipLinksClient) GetPreparer(resourceGroupName string, hubN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -272,13 +307,15 @@ func (client RelationshipLinksClient) GetResponder(resp *http.Response) (result func (client RelationshipLinksClient) ListByHub(resourceGroupName string, hubName string) (result RelationshipLinkListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipLinksClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -297,8 +334,9 @@ func (client RelationshipLinksClient) ListByHubPreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/relationships.go b/arm/customer-insights/relationships.go index 41c7d453dd6c..297835f2d103 100644 --- a/arm/customer-insights/relationships.go +++ b/arm/customer-insights/relationships.go @@ -54,7 +54,9 @@ func NewRelationshipsClientWithBaseURI(baseURI string, subscriptionID string) Re // resourceGroupName is the name of the resource group. hubName is the name of // the hub. relationshipName is the name of the Relationship. parameters is // parameters supplied to the CreateOrUpdate Relationship operation. -func (client RelationshipsClient) CreateOrUpdate(resourceGroupName string, hubName string, relationshipName string, parameters RelationshipResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client RelationshipsClient) CreateOrUpdate(resourceGroupName string, hubName string, relationshipName string, parameters RelationshipResourceFormat, cancel <-chan struct{}) (<-chan RelationshipResourceFormat, <-chan error) { + resultChan := make(chan RelationshipResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: relationshipName, Constraints: []validation.Constraint{{Target: "relationshipName", Name: validation.MaxLength, Rule: 512, Chain: nil}, @@ -65,26 +67,40 @@ func (client RelationshipsClient) CreateOrUpdate(resourceGroupName string, hubNa Chain: []validation.Constraint{{Target: "parameters.RelationshipDefinition.ProfileType", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.RelationshipDefinition.RelatedProfileType", Name: validation.Null, Rule: true, Chain: nil}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, relationshipName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result RelationshipResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, relationshipName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -96,8 +112,9 @@ func (client RelationshipsClient) CreateOrUpdatePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -120,13 +137,14 @@ func (client RelationshipsClient) CreateOrUpdateSender(req *http.Request) (*http // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client RelationshipsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client RelationshipsClient) CreateOrUpdateResponder(resp *http.Response) (result RelationshipResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -137,24 +155,37 @@ func (client RelationshipsClient) CreateOrUpdateResponder(resp *http.Response) ( // // resourceGroupName is the name of the resource group. hubName is the name of // the hub. relationshipName is the name of the relationship. -func (client RelationshipsClient) Delete(resourceGroupName string, hubName string, relationshipName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, hubName, relationshipName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Delete", resp, "Failure responding to request") - } - - return +func (client RelationshipsClient) Delete(resourceGroupName string, hubName string, relationshipName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, hubName, relationshipName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -166,8 +197,9 @@ func (client RelationshipsClient) DeletePreparer(resourceGroupName string, hubNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -205,13 +237,15 @@ func (client RelationshipsClient) DeleteResponder(resp *http.Response) (result a func (client RelationshipsClient) Get(resourceGroupName string, hubName string, relationshipName string) (result RelationshipResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, relationshipName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -231,8 +265,9 @@ func (client RelationshipsClient) GetPreparer(resourceGroupName string, hubName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -269,13 +304,15 @@ func (client RelationshipsClient) GetResponder(resp *http.Response) (result Rela func (client RelationshipsClient) ListByHub(resourceGroupName string, hubName string) (result RelationshipListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RelationshipsClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -294,8 +331,9 @@ func (client RelationshipsClient) ListByHubPreparer(resourceGroupName string, hu "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/roleassignments.go b/arm/customer-insights/roleassignments.go index b2d7160e3023..22b898812302 100644 --- a/arm/customer-insights/roleassignments.go +++ b/arm/customer-insights/roleassignments.go @@ -54,7 +54,9 @@ func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) // resourceGroupName is the name of the resource group. hubName is the name of // the hub. assignmentName is the assignment name parameters is parameters // supplied to the CreateOrUpdate RoleAssignment operation. -func (client RoleAssignmentsClient) CreateOrUpdate(resourceGroupName string, hubName string, assignmentName string, parameters RoleAssignmentResourceFormat, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client RoleAssignmentsClient) CreateOrUpdate(resourceGroupName string, hubName string, assignmentName string, parameters RoleAssignmentResourceFormat, cancel <-chan struct{}) (<-chan RoleAssignmentResourceFormat, <-chan error) { + resultChan := make(chan RoleAssignmentResourceFormat, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: assignmentName, Constraints: []validation.Constraint{{Target: "assignmentName", Name: validation.MaxLength, Rule: 128, Chain: nil}, @@ -63,26 +65,40 @@ func (client RoleAssignmentsClient) CreateOrUpdate(resourceGroupName string, hub {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.RoleAssignment", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.RoleAssignment.Principals", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate") + errChan <- validation.NewErrorWithValidationError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan } - req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, assignmentName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + go func() { + var err error + var result RoleAssignmentResourceFormat + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, assignmentName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -94,8 +110,9 @@ func (client RoleAssignmentsClient) CreateOrUpdatePreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -118,13 +135,14 @@ func (client RoleAssignmentsClient) CreateOrUpdateSender(req *http.Request) (*ht // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client RoleAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client RoleAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result RoleAssignmentResourceFormat, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -135,13 +153,15 @@ func (client RoleAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) func (client RoleAssignmentsClient) Delete(resourceGroupName string, hubName string, assignmentName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, hubName, assignmentName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -161,8 +181,9 @@ func (client RoleAssignmentsClient) DeletePreparer(resourceGroupName string, hub "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -198,13 +219,15 @@ func (client RoleAssignmentsClient) DeleteResponder(resp *http.Response) (result func (client RoleAssignmentsClient) Get(resourceGroupName string, hubName string, assignmentName string) (result RoleAssignmentResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, assignmentName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -224,8 +247,9 @@ func (client RoleAssignmentsClient) GetPreparer(resourceGroupName string, hubNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -262,13 +286,15 @@ func (client RoleAssignmentsClient) GetResponder(resp *http.Response) (result Ro func (client RoleAssignmentsClient) ListByHub(resourceGroupName string, hubName string) (result RoleAssignmentListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RoleAssignmentsClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -287,8 +313,9 @@ func (client RoleAssignmentsClient) ListByHubPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/roles.go b/arm/customer-insights/roles.go index 55cd705fb713..6f0bc7e77ef2 100644 --- a/arm/customer-insights/roles.go +++ b/arm/customer-insights/roles.go @@ -49,13 +49,15 @@ func NewRolesClientWithBaseURI(baseURI string, subscriptionID string) RolesClien func (client RolesClient) ListByHub(resourceGroupName string, hubName string) (result RoleListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.RolesClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.RolesClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.RolesClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.RolesClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -74,8 +76,9 @@ func (client RolesClient) ListByHubPreparer(resourceGroupName string, hubName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/customer-insights/version.go b/arm/customer-insights/version.go index 5739e803f309..02550b41899b 100644 --- a/arm/customer-insights/version.go +++ b/arm/customer-insights/version.go @@ -18,43 +18,12 @@ package customerinsights // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "customerinsights", "2017-01-01") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.0-beta arm-customerinsights/2017-01-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.0-beta" } diff --git a/arm/customer-insights/views.go b/arm/customer-insights/views.go index ab21ce9339d3..6eaba3d707aa 100644 --- a/arm/customer-insights/views.go +++ b/arm/customer-insights/views.go @@ -61,13 +61,15 @@ func (client ViewsClient) CreateOrUpdate(resourceGroupName string, hubName strin req, err := client.CreateOrUpdatePreparer(resourceGroupName, hubName, viewName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -87,8 +89,9 @@ func (client ViewsClient) CreateOrUpdatePreparer(resourceGroupName string, hubNa "viewName": autorest.Encode("path", viewName), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -128,13 +131,15 @@ func (client ViewsClient) CreateOrUpdateResponder(resp *http.Response) (result V func (client ViewsClient) Delete(resourceGroupName string, hubName string, viewName string, userID string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, hubName, viewName, userID) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -154,8 +159,9 @@ func (client ViewsClient) DeletePreparer(resourceGroupName string, hubName strin "viewName": autorest.Encode("path", viewName), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, "userId": autorest.Encode("query", userID), } @@ -193,13 +199,15 @@ func (client ViewsClient) DeleteResponder(resp *http.Response) (result autorest. func (client ViewsClient) Get(resourceGroupName string, hubName string, viewName string, userID string) (result ViewResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, viewName, userID) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -219,8 +227,9 @@ func (client ViewsClient) GetPreparer(resourceGroupName string, hubName string, "viewName": autorest.Encode("path", viewName), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, "userId": autorest.Encode("query", userID), } @@ -258,13 +267,15 @@ func (client ViewsClient) GetResponder(resp *http.Response) (result ViewResource func (client ViewsClient) ListByHub(resourceGroupName string, hubName string, userID string) (result ViewListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName, userID) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.ViewsClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -283,8 +294,9 @@ func (client ViewsClient) ListByHubPreparer(resourceGroupName string, hubName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, "userId": autorest.Encode("query", userID), } diff --git a/arm/customer-insights/widgettypes.go b/arm/customer-insights/widgettypes.go index 56f5fe6aabaa..120d613fbb37 100644 --- a/arm/customer-insights/widgettypes.go +++ b/arm/customer-insights/widgettypes.go @@ -50,13 +50,15 @@ func NewWidgetTypesClientWithBaseURI(baseURI string, subscriptionID string) Widg func (client WidgetTypesClient) Get(resourceGroupName string, hubName string, widgetTypeName string) (result WidgetTypeResourceFormat, err error) { req, err := client.GetPreparer(resourceGroupName, hubName, widgetTypeName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -76,8 +78,9 @@ func (client WidgetTypesClient) GetPreparer(resourceGroupName string, hubName st "widgetTypeName": autorest.Encode("path", widgetTypeName), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -114,13 +117,15 @@ func (client WidgetTypesClient) GetResponder(resp *http.Response) (result Widget func (client WidgetTypesClient) ListByHub(resourceGroupName string, hubName string) (result WidgetTypeListResult, err error) { req, err := client.ListByHubPreparer(resourceGroupName, hubName) if err != nil { - return result, autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "ListByHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "ListByHub", nil, "Failure preparing request") + return } resp, err := client.ListByHubSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "ListByHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "customerinsights.WidgetTypesClient", "ListByHub", resp, "Failure sending request") + return } result, err = client.ListByHubResponder(resp) @@ -139,8 +144,9 @@ func (client WidgetTypesClient) ListByHubPreparer(resourceGroupName string, hubN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2017-01-01" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/datalake-analytics/account/accountgroup.go b/arm/datalake-analytics/account/accountgroup.go index 857db12ce19a..e1791b1dacb0 100755 --- a/arm/datalake-analytics/account/accountgroup.go +++ b/arm/datalake-analytics/account/accountgroup.go @@ -51,7 +51,9 @@ func NewGroupClientWithBaseURI(baseURI string, subscriptionID string) GroupClien // Data Lake Analytics account.the account will be associated with. accountName // is the name of the Data Lake Analytics account to create. parameters is // parameters supplied to the create Data Lake Analytics account operation. -func (client GroupClient) Create(resourceGroupName string, accountName string, parameters DataLakeAnalyticsAccount, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) Create(resourceGroupName string, accountName string, parameters DataLakeAnalyticsAccount, cancel <-chan struct{}) (<-chan DataLakeAnalyticsAccount, <-chan error) { + resultChan := make(chan DataLakeAnalyticsAccount, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.DataLakeAnalyticsAccountProperties", Name: validation.Null, Rule: true, @@ -66,26 +68,40 @@ func (client GroupClient) Create(resourceGroupName string, accountName string, p Chain: []validation.Constraint{{Target: "parameters.DataLakeAnalyticsAccountProperties.MaxJobCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}, {Target: "parameters.DataLakeAnalyticsAccountProperties.DataLakeStoreAccounts", Name: validation.Null, Rule: true, Chain: nil}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "account.GroupClient", "Create") - } - - req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "account.GroupClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result DataLakeAnalyticsAccount + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -121,13 +137,14 @@ func (client GroupClient) CreateSender(req *http.Request) (*http.Response, error // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client GroupClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) CreateResponder(resp *http.Response) (result DataLakeAnalyticsAccount, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -139,24 +156,37 @@ func (client GroupClient) CreateResponder(resp *http.Response) (result autorest. // resourceGroupName is the name of the Azure resource group that contains the // Data Lake Analytics account. accountName is the name of the Data Lake // Analytics account to delete -func (client GroupClient) Delete(resourceGroupName string, accountName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, accountName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure responding to request") - } - - return +func (client GroupClient) Delete(resourceGroupName string, accountName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, accountName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -208,13 +238,15 @@ func (client GroupClient) DeleteResponder(resp *http.Response) (result autorest. func (client GroupClient) Get(resourceGroupName string, accountName string) (result DataLakeAnalyticsAccount, err error) { req, err := client.GetPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -291,13 +323,15 @@ func (client GroupClient) List(filter string, top *int32, skip *int32, selectPar req, err := client.ListPreparer(filter, top, skip, selectParameter, orderby, count) if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.GroupClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -416,13 +450,15 @@ func (client GroupClient) ListByResourceGroup(resourceGroupName string, filter s req, err := client.ListByResourceGroupPreparer(resourceGroupName, filter, top, skip, selectParameter, orderby, count) if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -524,24 +560,37 @@ func (client GroupClient) ListByResourceGroupNextResults(lastResults DataLakeAna // Data Lake Analytics account. accountName is the name of the Data Lake // Analytics account to update. parameters is parameters supplied to the update // Data Lake Analytics account operation. -func (client GroupClient) Update(resourceGroupName string, accountName string, parameters *DataLakeAnalyticsAccountUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Update", nil, "Failure preparing request") - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure sending request") - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure responding to request") - } - - return +func (client GroupClient) Update(resourceGroupName string, accountName string, parameters *DataLakeAnalyticsAccountUpdateParameters, cancel <-chan struct{}) (<-chan DataLakeAnalyticsAccount, <-chan error) { + resultChan := make(chan DataLakeAnalyticsAccount, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result DataLakeAnalyticsAccount + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -580,12 +629,13 @@ func (client GroupClient) UpdateSender(req *http.Request) (*http.Response, error // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client GroupClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) UpdateResponder(resp *http.Response) (result DataLakeAnalyticsAccount, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/datalake-analytics/account/datalakestoreaccounts.go b/arm/datalake-analytics/account/datalakestoreaccounts.go index 629fe0ef4f5d..81bfb42433eb 100755 --- a/arm/datalake-analytics/account/datalakestoreaccounts.go +++ b/arm/datalake-analytics/account/datalakestoreaccounts.go @@ -54,13 +54,15 @@ func NewDataLakeStoreAccountsClientWithBaseURI(baseURI string, subscriptionID st func (client DataLakeStoreAccountsClient) Add(resourceGroupName string, accountName string, dataLakeStoreAccountName string, parameters *AddDataLakeStoreParameters) (result autorest.Response, err error) { req, err := client.AddPreparer(resourceGroupName, accountName, dataLakeStoreAccountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", nil, "Failure preparing request") + return } resp, err := client.AddSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", resp, "Failure sending request") + return } result, err = client.AddResponder(resp) @@ -127,13 +129,15 @@ func (client DataLakeStoreAccountsClient) AddResponder(resp *http.Response) (res func (client DataLakeStoreAccountsClient) Delete(resourceGroupName string, accountName string, dataLakeStoreAccountName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, accountName, dataLakeStoreAccountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -195,13 +199,15 @@ func (client DataLakeStoreAccountsClient) DeleteResponder(resp *http.Response) ( func (client DataLakeStoreAccountsClient) Get(resourceGroupName string, accountName string, dataLakeStoreAccountName string) (result DataLakeStoreAccountInfo, err error) { req, err := client.GetPreparer(resourceGroupName, accountName, dataLakeStoreAccountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -283,13 +289,15 @@ func (client DataLakeStoreAccountsClient) ListByAccount(resourceGroupName string req, err := client.ListByAccountPreparer(resourceGroupName, accountName, filter, top, skip, selectParameter, orderby, count) if err != nil { - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", nil, "Failure preparing request") + return } resp, err := client.ListByAccountSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", resp, "Failure sending request") + return } result, err = client.ListByAccountResponder(resp) diff --git a/arm/datalake-analytics/account/firewallrules.go b/arm/datalake-analytics/account/firewallrules.go index 043ba81e8198..deeb03252089 100755 --- a/arm/datalake-analytics/account/firewallrules.go +++ b/arm/datalake-analytics/account/firewallrules.go @@ -64,13 +64,15 @@ func (client FirewallRulesClient) CreateOrUpdate(resourceGroupName string, accou req, err := client.CreateOrUpdatePreparer(resourceGroupName, accountName, firewallRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -134,13 +136,15 @@ func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) ( func (client FirewallRulesClient) Delete(resourceGroupName string, accountName string, firewallRuleName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, accountName, firewallRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -200,13 +204,15 @@ func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result a func (client FirewallRulesClient) Get(resourceGroupName string, accountName string, firewallRuleName string) (result FirewallRule, err error) { req, err := client.GetPreparer(resourceGroupName, accountName, firewallRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -267,13 +273,15 @@ func (client FirewallRulesClient) GetResponder(resp *http.Response) (result Fire func (client FirewallRulesClient) ListByAccount(resourceGroupName string, accountName string) (result DataLakeAnalyticsFirewallRuleListResult, err error) { req, err := client.ListByAccountPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", nil, "Failure preparing request") + return } resp, err := client.ListByAccountSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", resp, "Failure sending request") + return } result, err = client.ListByAccountResponder(resp) @@ -358,13 +366,15 @@ func (client FirewallRulesClient) ListByAccountNextResults(lastResults DataLakeA func (client FirewallRulesClient) Update(resourceGroupName string, accountName string, firewallRuleName string, parameters *UpdateFirewallRuleParameters) (result FirewallRule, err error) { req, err := client.UpdatePreparer(resourceGroupName, accountName, firewallRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/datalake-analytics/account/storageaccounts.go b/arm/datalake-analytics/account/storageaccounts.go index 4a9089d3cb72..d0f823938fb6 100755 --- a/arm/datalake-analytics/account/storageaccounts.go +++ b/arm/datalake-analytics/account/storageaccounts.go @@ -62,13 +62,15 @@ func (client StorageAccountsClient) Add(resourceGroupName string, accountName st req, err := client.AddPreparer(resourceGroupName, accountName, storageAccountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Add", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Add", nil, "Failure preparing request") + return } resp, err := client.AddSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Add", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Add", resp, "Failure sending request") + return } result, err = client.AddResponder(resp) @@ -131,13 +133,15 @@ func (client StorageAccountsClient) AddResponder(resp *http.Response) (result au func (client StorageAccountsClient) Delete(resourceGroupName string, accountName string, storageAccountName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, accountName, storageAccountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -199,13 +203,15 @@ func (client StorageAccountsClient) DeleteResponder(resp *http.Response) (result func (client StorageAccountsClient) Get(resourceGroupName string, accountName string, storageAccountName string) (result StorageAccountInfo, err error) { req, err := client.GetPreparer(resourceGroupName, accountName, storageAccountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -269,13 +275,15 @@ func (client StorageAccountsClient) GetResponder(resp *http.Response) (result St func (client StorageAccountsClient) GetStorageContainer(resourceGroupName string, accountName string, storageAccountName string, containerName string) (result StorageContainer, err error) { req, err := client.GetStorageContainerPreparer(resourceGroupName, accountName, storageAccountName, containerName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "GetStorageContainer", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "GetStorageContainer", nil, "Failure preparing request") + return } resp, err := client.GetStorageContainerSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "GetStorageContainer", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "GetStorageContainer", resp, "Failure sending request") + return } result, err = client.GetStorageContainerResponder(resp) @@ -358,13 +366,15 @@ func (client StorageAccountsClient) ListByAccount(resourceGroupName string, acco req, err := client.ListByAccountPreparer(resourceGroupName, accountName, filter, top, skip, selectParameter, orderby, count) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListByAccount", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListByAccount", nil, "Failure preparing request") + return } resp, err := client.ListByAccountSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListByAccount", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListByAccount", resp, "Failure sending request") + return } result, err = client.ListByAccountResponder(resp) @@ -469,13 +479,15 @@ func (client StorageAccountsClient) ListByAccountNextResults(lastResults DataLak func (client StorageAccountsClient) ListSasTokens(resourceGroupName string, accountName string, storageAccountName string, containerName string) (result ListSasTokensResult, err error) { req, err := client.ListSasTokensPreparer(resourceGroupName, accountName, storageAccountName, containerName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListSasTokens", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListSasTokens", nil, "Failure preparing request") + return } resp, err := client.ListSasTokensSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListSasTokens", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListSasTokens", resp, "Failure sending request") + return } result, err = client.ListSasTokensResponder(resp) @@ -565,13 +577,15 @@ func (client StorageAccountsClient) ListSasTokensNextResults(lastResults ListSas func (client StorageAccountsClient) ListStorageContainers(resourceGroupName string, accountName string, storageAccountName string) (result ListStorageContainersResult, err error) { req, err := client.ListStorageContainersPreparer(resourceGroupName, accountName, storageAccountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListStorageContainers", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListStorageContainers", nil, "Failure preparing request") + return } resp, err := client.ListStorageContainersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListStorageContainers", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "ListStorageContainers", resp, "Failure sending request") + return } result, err = client.ListStorageContainersResponder(resp) @@ -659,13 +673,15 @@ func (client StorageAccountsClient) ListStorageContainersNextResults(lastResults func (client StorageAccountsClient) Update(resourceGroupName string, accountName string, storageAccountName string, parameters *UpdateStorageAccountParameters) (result autorest.Response, err error) { req, err := client.UpdatePreparer(resourceGroupName, accountName, storageAccountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.StorageAccountsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/datalake-analytics/account/version.go b/arm/datalake-analytics/account/version.go index 6d5381fe019c..6822ddad0388 100755 --- a/arm/datalake-analytics/account/version.go +++ b/arm/datalake-analytics/account/version.go @@ -20,10 +20,10 @@ package account // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-account/2016-11-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-account/2016-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/datalake-store/account/accountgroup.go b/arm/datalake-store/account/accountgroup.go index 7e50c31ecd10..50042ad67aac 100755 --- a/arm/datalake-store/account/accountgroup.go +++ b/arm/datalake-store/account/accountgroup.go @@ -50,7 +50,9 @@ func NewGroupClientWithBaseURI(baseURI string, subscriptionID string) GroupClien // Data Lake Store account. name is the name of the Data Lake Store account to // create. parameters is parameters supplied to create the Data Lake Store // account. -func (client GroupClient) Create(resourceGroupName string, name string, parameters DataLakeStoreAccount, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client GroupClient) Create(resourceGroupName string, name string, parameters DataLakeStoreAccount, cancel <-chan struct{}) (<-chan DataLakeStoreAccount, <-chan error) { + resultChan := make(chan DataLakeStoreAccount, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Identity", Name: validation.Null, Rule: false, @@ -64,26 +66,40 @@ func (client GroupClient) Create(resourceGroupName string, name string, paramete }}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "account.GroupClient", "Create") - } - - req, err := client.CreatePreparer(resourceGroupName, name, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "account.GroupClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result DataLakeStoreAccount + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, name, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreatePreparer prepares the Create request. @@ -119,13 +135,14 @@ func (client GroupClient) CreateSender(req *http.Request) (*http.Response, error // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. -func (client GroupClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) CreateResponder(resp *http.Response) (result DataLakeStoreAccount, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -137,24 +154,37 @@ func (client GroupClient) CreateResponder(resp *http.Response) (result autorest. // resourceGroupName is the name of the Azure resource group that contains the // Data Lake Store account. name is the name of the Data Lake Store account to // delete. -func (client GroupClient) Delete(resourceGroupName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure responding to request") - } - - return +func (client GroupClient) Delete(resourceGroupName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -207,13 +237,15 @@ func (client GroupClient) DeleteResponder(resp *http.Response) (result autorest. func (client GroupClient) EnableKeyVault(resourceGroupName string, accountName string) (result autorest.Response, err error) { req, err := client.EnableKeyVaultPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "EnableKeyVault", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "EnableKeyVault", nil, "Failure preparing request") + return } resp, err := client.EnableKeyVaultSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.GroupClient", "EnableKeyVault", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "EnableKeyVault", resp, "Failure sending request") + return } result, err = client.EnableKeyVaultResponder(resp) @@ -271,13 +303,15 @@ func (client GroupClient) EnableKeyVaultResponder(resp *http.Response) (result a func (client GroupClient) Get(resourceGroupName string, name string) (result DataLakeStoreAccount, err error) { req, err := client.GetPreparer(resourceGroupName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -354,13 +388,15 @@ func (client GroupClient) List(filter string, top *int32, skip *int32, selectPar req, err := client.ListPreparer(filter, top, skip, selectParameter, orderby, count) if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.GroupClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -479,13 +515,15 @@ func (client GroupClient) ListByResourceGroup(resourceGroupName string, filter s req, err := client.ListByResourceGroupPreparer(resourceGroupName, filter, top, skip, selectParameter, orderby, count) if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.GroupClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -586,24 +624,37 @@ func (client GroupClient) ListByResourceGroupNextResults(lastResults DataLakeSto // Data Lake Store account. name is the name of the Data Lake Store account to // update. parameters is parameters supplied to update the Data Lake Store // account. -func (client GroupClient) Update(resourceGroupName string, name string, parameters DataLakeStoreAccountUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.UpdatePreparer(resourceGroupName, name, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Update", nil, "Failure preparing request") - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure sending request") - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure responding to request") - } - - return +func (client GroupClient) Update(resourceGroupName string, name string, parameters DataLakeStoreAccountUpdateParameters, cancel <-chan struct{}) (<-chan DataLakeStoreAccount, <-chan error) { + resultChan := make(chan DataLakeStoreAccount, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result DataLakeStoreAccount + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, name, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "account.GroupClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -639,12 +690,13 @@ func (client GroupClient) UpdateSender(req *http.Request) (*http.Response, error // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client GroupClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client GroupClient) UpdateResponder(resp *http.Response) (result DataLakeStoreAccount, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/datalake-store/account/firewallrules.go b/arm/datalake-store/account/firewallrules.go index 31e24f5f8d7f..cd27b5ee1237 100755 --- a/arm/datalake-store/account/firewallrules.go +++ b/arm/datalake-store/account/firewallrules.go @@ -64,13 +64,15 @@ func (client FirewallRulesClient) CreateOrUpdate(resourceGroupName string, accou req, err := client.CreateOrUpdatePreparer(resourceGroupName, accountName, firewallRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -134,13 +136,15 @@ func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) ( func (client FirewallRulesClient) Delete(resourceGroupName string, accountName string, firewallRuleName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, accountName, firewallRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -200,13 +204,15 @@ func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result a func (client FirewallRulesClient) Get(resourceGroupName string, accountName string, firewallRuleName string) (result FirewallRule, err error) { req, err := client.GetPreparer(resourceGroupName, accountName, firewallRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -267,13 +273,15 @@ func (client FirewallRulesClient) GetResponder(resp *http.Response) (result Fire func (client FirewallRulesClient) ListByAccount(resourceGroupName string, accountName string) (result DataLakeStoreFirewallRuleListResult, err error) { req, err := client.ListByAccountPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", nil, "Failure preparing request") + return } resp, err := client.ListByAccountSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "ListByAccount", resp, "Failure sending request") + return } result, err = client.ListByAccountResponder(resp) @@ -358,13 +366,15 @@ func (client FirewallRulesClient) ListByAccountNextResults(lastResults DataLakeS func (client FirewallRulesClient) Update(resourceGroupName string, accountName string, firewallRuleName string, parameters *UpdateFirewallRuleParameters) (result FirewallRule, err error) { req, err := client.UpdatePreparer(resourceGroupName, accountName, firewallRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.FirewallRulesClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/datalake-store/account/trustedidproviders.go b/arm/datalake-store/account/trustedidproviders.go index 33d603665b66..9411268b32a3 100755 --- a/arm/datalake-store/account/trustedidproviders.go +++ b/arm/datalake-store/account/trustedidproviders.go @@ -63,13 +63,15 @@ func (client TrustedIDProvidersClient) CreateOrUpdate(resourceGroupName string, req, err := client.CreateOrUpdatePreparer(resourceGroupName, accountName, trustedIDProviderName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -134,13 +136,15 @@ func (client TrustedIDProvidersClient) CreateOrUpdateResponder(resp *http.Respon func (client TrustedIDProvidersClient) Delete(resourceGroupName string, accountName string, trustedIDProviderName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, accountName, trustedIDProviderName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -201,13 +205,15 @@ func (client TrustedIDProvidersClient) DeleteResponder(resp *http.Response) (res func (client TrustedIDProvidersClient) Get(resourceGroupName string, accountName string, trustedIDProviderName string) (result TrustedIDProvider, err error) { req, err := client.GetPreparer(resourceGroupName, accountName, trustedIDProviderName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -268,13 +274,15 @@ func (client TrustedIDProvidersClient) GetResponder(resp *http.Response) (result func (client TrustedIDProvidersClient) ListByAccount(resourceGroupName string, accountName string) (result DataLakeStoreTrustedIDProviderListResult, err error) { req, err := client.ListByAccountPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "ListByAccount", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "ListByAccount", nil, "Failure preparing request") + return } resp, err := client.ListByAccountSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "ListByAccount", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "ListByAccount", resp, "Failure sending request") + return } result, err = client.ListByAccountResponder(resp) @@ -360,13 +368,15 @@ func (client TrustedIDProvidersClient) ListByAccountNextResults(lastResults Data func (client TrustedIDProvidersClient) Update(resourceGroupName string, accountName string, trustedIDProviderName string, parameters *UpdateTrustedIDProviderParameters) (result TrustedIDProvider, err error) { req, err := client.UpdatePreparer(resourceGroupName, accountName, trustedIDProviderName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "account.TrustedIDProvidersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/datalake-store/account/version.go b/arm/datalake-store/account/version.go index 6d5381fe019c..6822ddad0388 100755 --- a/arm/datalake-store/account/version.go +++ b/arm/datalake-store/account/version.go @@ -20,10 +20,10 @@ package account // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-account/2016-11-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-account/2016-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/devtestlabs/armtemplates.go b/arm/devtestlabs/armtemplates.go new file mode 100644 index 000000000000..1e017dc103f8 --- /dev/null +++ b/arm/devtestlabs/armtemplates.go @@ -0,0 +1,221 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ArmTemplatesClient is the the DevTest Labs Client. +type ArmTemplatesClient struct { + ManagementClient +} + +// NewArmTemplatesClient creates an instance of the ArmTemplatesClient client. +func NewArmTemplatesClient(subscriptionID string) ArmTemplatesClient { + return NewArmTemplatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewArmTemplatesClientWithBaseURI creates an instance of the +// ArmTemplatesClient client. +func NewArmTemplatesClientWithBaseURI(baseURI string, subscriptionID string) ArmTemplatesClient { + return ArmTemplatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get azure resource manager template. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. artifactSourceName is the name of the artifact source. name is the +// name of the azure Resource Manager template. expand is specify the $expand +// query. Example: 'properties($select=displayName)' +func (client ArmTemplatesClient) Get(resourceGroupName string, labName string, artifactSourceName string, name string, expand string) (result ArmTemplate, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, artifactSourceName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ArmTemplatesClient) GetPreparer(resourceGroupName string, labName string, artifactSourceName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "artifactSourceName": autorest.Encode("path", artifactSourceName), + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ArmTemplatesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ArmTemplatesClient) GetResponder(resp *http.Response) (result ArmTemplate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list azure resource manager templates in a given artifact source. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. artifactSourceName is the name of the artifact source. expand is +// specify the $expand query. Example: 'properties($select=displayName)' filter +// is the filter to apply to the operation. top is the maximum number of +// resources to return from the operation. orderby is the ordering expression +// for the results, using OData notation. +func (client ArmTemplatesClient) List(resourceGroupName string, labName string, artifactSourceName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationArmTemplate, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, artifactSourceName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ArmTemplatesClient) ListPreparer(resourceGroupName string, labName string, artifactSourceName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "artifactSourceName": autorest.Encode("path", artifactSourceName), + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/armtemplates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ArmTemplatesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ArmTemplatesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationArmTemplate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ArmTemplatesClient) ListNextResults(lastResults ResponseWithContinuationArmTemplate) (result ResponseWithContinuationArmTemplate, err error) { + req, err := lastResults.ResponseWithContinuationArmTemplatePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ArmTemplatesClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/devtestlabs/artifactoperations.go b/arm/devtestlabs/artifacts.go similarity index 56% rename from arm/devtestlabs/artifactoperations.go rename to arm/devtestlabs/artifacts.go index ab7f185b086f..eaed0a1aa612 100644 --- a/arm/devtestlabs/artifactoperations.go +++ b/arm/devtestlabs/artifacts.go @@ -14,7 +14,7 @@ package devtestlabs // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,52 +24,54 @@ import ( "net/http" ) -// ArtifactOperationsClient is the azure DevTest Labs REST API. -type ArtifactOperationsClient struct { +// ArtifactsClient is the the DevTest Labs Client. +type ArtifactsClient struct { ManagementClient } -// NewArtifactOperationsClient creates an instance of the -// ArtifactOperationsClient client. -func NewArtifactOperationsClient(subscriptionID string) ArtifactOperationsClient { - return NewArtifactOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +// NewArtifactsClient creates an instance of the ArtifactsClient client. +func NewArtifactsClient(subscriptionID string) ArtifactsClient { + return NewArtifactsClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewArtifactOperationsClientWithBaseURI creates an instance of the -// ArtifactOperationsClient client. -func NewArtifactOperationsClientWithBaseURI(baseURI string, subscriptionID string) ArtifactOperationsClient { - return ArtifactOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +// NewArtifactsClientWithBaseURI creates an instance of the ArtifactsClient +// client. +func NewArtifactsClientWithBaseURI(baseURI string, subscriptionID string) ArtifactsClient { + return ArtifactsClient{NewWithBaseURI(baseURI, subscriptionID)} } // GenerateArmTemplate generates an ARM template for the given artifact, -// uploads the required files to a storage account, and validates the -// generated artifact. +// uploads the required files to a storage account, and validates the generated +// artifact. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. artifactSourceName is the name of the artifact source. name is -// the name of the artifact. -func (client ArtifactOperationsClient) GenerateArmTemplate(resourceGroupName string, labName string, artifactSourceName string, name string, generateArmTemplateRequest GenerateArmTemplateRequest) (result ArmTemplateInfo, err error) { +// the lab. artifactSourceName is the name of the artifact source. name is the +// name of the artifact. generateArmTemplateRequest is parameters for +// generating an ARM template for deploying artifacts. +func (client ArtifactsClient) GenerateArmTemplate(resourceGroupName string, labName string, artifactSourceName string, name string, generateArmTemplateRequest GenerateArmTemplateRequest) (result ArmTemplateInfo, err error) { req, err := client.GenerateArmTemplatePreparer(resourceGroupName, labName, artifactSourceName, name, generateArmTemplateRequest) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "GenerateArmTemplate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "GenerateArmTemplate", nil, "Failure preparing request") + return } resp, err := client.GenerateArmTemplateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "GenerateArmTemplate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "GenerateArmTemplate", resp, "Failure sending request") + return } result, err = client.GenerateArmTemplateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "GenerateArmTemplate", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "GenerateArmTemplate", resp, "Failure responding to request") } return } // GenerateArmTemplatePreparer prepares the GenerateArmTemplate request. -func (client ArtifactOperationsClient) GenerateArmTemplatePreparer(resourceGroupName string, labName string, artifactSourceName string, name string, generateArmTemplateRequest GenerateArmTemplateRequest) (*http.Request, error) { +func (client ArtifactsClient) GenerateArmTemplatePreparer(resourceGroupName string, labName string, artifactSourceName string, name string, generateArmTemplateRequest GenerateArmTemplateRequest) (*http.Request, error) { pathParameters := map[string]interface{}{ "artifactSourceName": autorest.Encode("path", artifactSourceName), "labName": autorest.Encode("path", labName), @@ -78,8 +80,9 @@ func (client ArtifactOperationsClient) GenerateArmTemplatePreparer(resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -94,13 +97,13 @@ func (client ArtifactOperationsClient) GenerateArmTemplatePreparer(resourceGroup // GenerateArmTemplateSender sends the GenerateArmTemplate request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactOperationsClient) GenerateArmTemplateSender(req *http.Request) (*http.Response, error) { +func (client ArtifactsClient) GenerateArmTemplateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } // GenerateArmTemplateResponder handles the response to the GenerateArmTemplate request. The method always // closes the http.Response Body. -func (client ArtifactOperationsClient) GenerateArmTemplateResponder(resp *http.Response) (result ArmTemplateInfo, err error) { +func (client ArtifactsClient) GenerateArmTemplateResponder(resp *http.Response) (result ArmTemplateInfo, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -111,33 +114,36 @@ func (client ArtifactOperationsClient) GenerateArmTemplateResponder(resp *http.R return } -// GetResource get artifact. +// Get get artifact. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. artifactSourceName is the name of the artifact source. name is -// the name of the artifact. -func (client ArtifactOperationsClient) GetResource(resourceGroupName string, labName string, artifactSourceName string, name string) (result Artifact, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, artifactSourceName, name) +// the lab. artifactSourceName is the name of the artifact source. name is the +// name of the artifact. expand is specify the $expand query. Example: +// 'properties($select=title)' +func (client ArtifactsClient) Get(resourceGroupName string, labName string, artifactSourceName string, name string, expand string) (result Artifact, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, artifactSourceName, name, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "GetResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "Get", nil, "Failure preparing request") + return } - resp, err := client.GetResourceSender(req) + resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "GetResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "Get", resp, "Failure sending request") + return } - result, err = client.GetResourceResponder(resp) + result, err = client.GetResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "GetResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "Get", resp, "Failure responding to request") } return } -// GetResourcePreparer prepares the GetResource request. -func (client ArtifactOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, artifactSourceName string, name string) (*http.Request, error) { +// GetPreparer prepares the Get request. +func (client ArtifactsClient) GetPreparer(resourceGroupName string, labName string, artifactSourceName string, name string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ "artifactSourceName": autorest.Encode("path", artifactSourceName), "labName": autorest.Encode("path", labName), @@ -146,8 +152,12 @@ func (client ArtifactOperationsClient) GetResourcePreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } preparer := autorest.CreatePreparer( @@ -158,15 +168,15 @@ func (client ArtifactOperationsClient) GetResourcePreparer(resourceGroupName str return preparer.Prepare(&http.Request{}) } -// GetResourceSender sends the GetResource request. The method will close the +// GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { +func (client ArtifactsClient) GetSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// GetResourceResponder handles the response to the GetResource request. The method always +// GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client ArtifactOperationsClient) GetResourceResponder(resp *http.Response) (result Artifact, err error) { +func (client ArtifactsClient) GetResponder(resp *http.Response) (result Artifact, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -180,32 +190,35 @@ func (client ArtifactOperationsClient) GetResourceResponder(resp *http.Response) // List list artifacts in a given artifact source. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. artifactSourceName is the name of the artifact source. filter is -// the filter to apply on the operation. top is the maximum number of -// resources to return from the operation. orderBy is the ordering expression -// for the results, using OData notation. -func (client ArtifactOperationsClient) List(resourceGroupName string, labName string, artifactSourceName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationArtifact, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, artifactSourceName, filter, top, orderBy) +// the lab. artifactSourceName is the name of the artifact source. expand is +// specify the $expand query. Example: 'properties($select=title)' filter is +// the filter to apply to the operation. top is the maximum number of resources +// to return from the operation. orderby is the ordering expression for the +// results, using OData notation. +func (client ArtifactsClient) List(resourceGroupName string, labName string, artifactSourceName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationArtifact, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, artifactSourceName, expand, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "List", resp, "Failure responding to request") } return } // ListPreparer prepares the List request. -func (client ArtifactOperationsClient) ListPreparer(resourceGroupName string, labName string, artifactSourceName string, filter string, top *int32, orderBy string) (*http.Request, error) { +func (client ArtifactsClient) ListPreparer(resourceGroupName string, labName string, artifactSourceName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { pathParameters := map[string]interface{}{ "artifactSourceName": autorest.Encode("path", artifactSourceName), "labName": autorest.Encode("path", labName), @@ -213,8 +226,12 @@ func (client ArtifactOperationsClient) ListPreparer(resourceGroupName string, la "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -222,8 +239,8 @@ func (client ArtifactOperationsClient) ListPreparer(resourceGroupName string, la if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) } preparer := autorest.CreatePreparer( @@ -236,13 +253,13 @@ func (client ArtifactOperationsClient) ListPreparer(resourceGroupName string, la // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactOperationsClient) ListSender(req *http.Request) (*http.Response, error) { +func (client ArtifactsClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client ArtifactOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationArtifact, err error) { +func (client ArtifactsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationArtifact, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -254,10 +271,10 @@ func (client ArtifactOperationsClient) ListResponder(resp *http.Response) (resul } // ListNextResults retrieves the next set of results, if any. -func (client ArtifactOperationsClient) ListNextResults(lastResults ResponseWithContinuationArtifact) (result ResponseWithContinuationArtifact, err error) { +func (client ArtifactsClient) ListNextResults(lastResults ResponseWithContinuationArtifact) (result ResponseWithContinuationArtifact, err error) { req, err := lastResults.ResponseWithContinuationArtifactPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "List", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "List", nil, "Failure preparing next results request") } if req == nil { return @@ -266,12 +283,12 @@ func (client ArtifactOperationsClient) ListNextResults(lastResults ResponseWithC resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "List", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "List", resp, "Failure sending next results request") } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactOperationsClient", "List", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactsClient", "List", resp, "Failure responding to next results request") } return diff --git a/arm/devtestlabs/artifactsourceoperations.go b/arm/devtestlabs/artifactsources.go similarity index 50% rename from arm/devtestlabs/artifactsourceoperations.go rename to arm/devtestlabs/artifactsources.go index 8eabdd53887e..20b7306a45d8 100644 --- a/arm/devtestlabs/artifactsourceoperations.go +++ b/arm/devtestlabs/artifactsources.go @@ -14,59 +14,69 @@ package devtestlabs // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" "net/http" ) -// ArtifactSourceOperationsClient is the azure DevTest Labs REST API. -type ArtifactSourceOperationsClient struct { +// ArtifactSourcesClient is the the DevTest Labs Client. +type ArtifactSourcesClient struct { ManagementClient } -// NewArtifactSourceOperationsClient creates an instance of the -// ArtifactSourceOperationsClient client. -func NewArtifactSourceOperationsClient(subscriptionID string) ArtifactSourceOperationsClient { - return NewArtifactSourceOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +// NewArtifactSourcesClient creates an instance of the ArtifactSourcesClient +// client. +func NewArtifactSourcesClient(subscriptionID string) ArtifactSourcesClient { + return NewArtifactSourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewArtifactSourceOperationsClientWithBaseURI creates an instance of the -// ArtifactSourceOperationsClient client. -func NewArtifactSourceOperationsClientWithBaseURI(baseURI string, subscriptionID string) ArtifactSourceOperationsClient { - return ArtifactSourceOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +// NewArtifactSourcesClientWithBaseURI creates an instance of the +// ArtifactSourcesClient client. +func NewArtifactSourcesClientWithBaseURI(baseURI string, subscriptionID string) ArtifactSourcesClient { + return ArtifactSourcesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdateResource create or replace an existing artifact source. +// CreateOrUpdate create or replace an existing artifact source. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the artifact source. -func (client ArtifactSourceOperationsClient) CreateOrUpdateResource(resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (result ArtifactSource, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, labName, name, artifactSource) +// the lab. name is the name of the artifact source. artifactSource is +// properties of an artifact source. +func (client ArtifactSourcesClient) CreateOrUpdate(resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (result ArtifactSource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: artifactSource, + Constraints: []validation.Constraint{{Target: "artifactSource.ArtifactSourceProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.ArtifactSourcesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, artifactSource) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "CreateOrUpdateResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } - resp, err := client.CreateOrUpdateResourceSender(req) + resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "CreateOrUpdateResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "CreateOrUpdate", resp, "Failure sending request") + return } - result, err = client.CreateOrUpdateResourceResponder(resp) + result, err = client.CreateOrUpdateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "CreateOrUpdateResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "CreateOrUpdate", resp, "Failure responding to request") } return } -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client ArtifactSourceOperationsClient) CreateOrUpdateResourcePreparer(resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (*http.Request, error) { +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ArtifactSourcesClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -74,8 +84,9 @@ func (client ArtifactSourceOperationsClient) CreateOrUpdateResourcePreparer(reso "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -88,15 +99,15 @@ func (client ArtifactSourceOperationsClient) CreateOrUpdateResourcePreparer(reso return preparer.Prepare(&http.Request{}) } -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactSourceOperationsClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { +func (client ArtifactSourcesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ArtifactSourceOperationsClient) CreateOrUpdateResourceResponder(resp *http.Response) (result ArtifactSource, err error) { +func (client ArtifactSourcesClient) CreateOrUpdateResponder(resp *http.Response) (result ArtifactSource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -107,32 +118,34 @@ func (client ArtifactSourceOperationsClient) CreateOrUpdateResourceResponder(res return } -// DeleteResource delete artifact source. +// Delete delete artifact source. // // resourceGroupName is the name of the resource group. labName is the name of // the lab. name is the name of the artifact source. -func (client ArtifactSourceOperationsClient) DeleteResource(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, labName, name) +func (client ArtifactSourcesClient) Delete(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "DeleteResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Delete", nil, "Failure preparing request") + return } - resp, err := client.DeleteResourceSender(req) + resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "DeleteResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Delete", resp, "Failure sending request") + return } - result, err = client.DeleteResourceResponder(resp) + result, err = client.DeleteResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "DeleteResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Delete", resp, "Failure responding to request") } return } -// DeleteResourcePreparer prepares the DeleteResource request. -func (client ArtifactSourceOperationsClient) DeleteResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { +// DeletePreparer prepares the Delete request. +func (client ArtifactSourcesClient) DeletePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -140,8 +153,9 @@ func (client ArtifactSourceOperationsClient) DeleteResourcePreparer(resourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -152,15 +166,15 @@ func (client ArtifactSourceOperationsClient) DeleteResourcePreparer(resourceGrou return preparer.Prepare(&http.Request{}) } -// DeleteResourceSender sends the DeleteResource request. The method will close the +// DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactSourceOperationsClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { +func (client ArtifactSourcesClient) DeleteSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// DeleteResourceResponder handles the response to the DeleteResource request. The method always +// DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client ArtifactSourceOperationsClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ArtifactSourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -170,32 +184,35 @@ func (client ArtifactSourceOperationsClient) DeleteResourceResponder(resp *http. return } -// GetResource get artifact source. +// Get get artifact source. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the artifact source. -func (client ArtifactSourceOperationsClient) GetResource(resourceGroupName string, labName string, name string) (result ArtifactSource, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, name) +// the lab. name is the name of the artifact source. expand is specify the +// $expand query. Example: 'properties($select=displayName)' +func (client ArtifactSourcesClient) Get(resourceGroupName string, labName string, name string, expand string) (result ArtifactSource, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "GetResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Get", nil, "Failure preparing request") + return } - resp, err := client.GetResourceSender(req) + resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "GetResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Get", resp, "Failure sending request") + return } - result, err = client.GetResourceResponder(resp) + result, err = client.GetResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "GetResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Get", resp, "Failure responding to request") } return } -// GetResourcePreparer prepares the GetResource request. -func (client ArtifactSourceOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { +// GetPreparer prepares the Get request. +func (client ArtifactSourcesClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -203,8 +220,12 @@ func (client ArtifactSourceOperationsClient) GetResourcePreparer(resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } preparer := autorest.CreatePreparer( @@ -215,15 +236,15 @@ func (client ArtifactSourceOperationsClient) GetResourcePreparer(resourceGroupNa return preparer.Prepare(&http.Request{}) } -// GetResourceSender sends the GetResource request. The method will close the +// GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactSourceOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { +func (client ArtifactSourcesClient) GetSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// GetResourceResponder handles the response to the GetResource request. The method always +// GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client ArtifactSourceOperationsClient) GetResourceResponder(resp *http.Response) (result ArtifactSource, err error) { +func (client ArtifactSourcesClient) GetResponder(resp *http.Response) (result ArtifactSource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -237,39 +258,47 @@ func (client ArtifactSourceOperationsClient) GetResourceResponder(resp *http.Res // List list artifact sources in a given lab. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. filter is the filter to apply on the operation. top is the -// maximum number of resources to return from the operation. orderBy is the -// ordering expression for the results, using OData notation. -func (client ArtifactSourceOperationsClient) List(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationArtifactSource, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderBy) +// the lab. expand is specify the $expand query. Example: +// 'properties($select=displayName)' filter is the filter to apply to the +// operation. top is the maximum number of resources to return from the +// operation. orderby is the ordering expression for the results, using OData +// notation. +func (client ArtifactSourcesClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationArtifactSource, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "List", resp, "Failure responding to request") } return } // ListPreparer prepares the List request. -func (client ArtifactSourceOperationsClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) { +func (client ArtifactSourcesClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -277,8 +306,8 @@ func (client ArtifactSourceOperationsClient) ListPreparer(resourceGroupName stri if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) } preparer := autorest.CreatePreparer( @@ -291,13 +320,13 @@ func (client ArtifactSourceOperationsClient) ListPreparer(resourceGroupName stri // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactSourceOperationsClient) ListSender(req *http.Request) (*http.Response, error) { +func (client ArtifactSourcesClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client ArtifactSourceOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationArtifactSource, err error) { +func (client ArtifactSourcesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationArtifactSource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -309,10 +338,10 @@ func (client ArtifactSourceOperationsClient) ListResponder(resp *http.Response) } // ListNextResults retrieves the next set of results, if any. -func (client ArtifactSourceOperationsClient) ListNextResults(lastResults ResponseWithContinuationArtifactSource) (result ResponseWithContinuationArtifactSource, err error) { +func (client ArtifactSourcesClient) ListNextResults(lastResults ResponseWithContinuationArtifactSource) (result ResponseWithContinuationArtifactSource, err error) { req, err := lastResults.ResponseWithContinuationArtifactSourcePreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "List", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "List", nil, "Failure preparing next results request") } if req == nil { return @@ -321,43 +350,46 @@ func (client ArtifactSourceOperationsClient) ListNextResults(lastResults Respons resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "List", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "List", resp, "Failure sending next results request") } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "List", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "List", resp, "Failure responding to next results request") } return } -// PatchResource modify properties of artifact sources. +// Update modify properties of artifact sources. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the artifact source. -func (client ArtifactSourceOperationsClient) PatchResource(resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (result ArtifactSource, err error) { - req, err := client.PatchResourcePreparer(resourceGroupName, labName, name, artifactSource) +// the lab. name is the name of the artifact source. artifactSource is +// properties of an artifact source. +func (client ArtifactSourcesClient) Update(resourceGroupName string, labName string, name string, artifactSource ArtifactSourceFragment) (result ArtifactSource, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, name, artifactSource) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "PatchResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Update", nil, "Failure preparing request") + return } - resp, err := client.PatchResourceSender(req) + resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "PatchResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Update", resp, "Failure sending request") + return } - result, err = client.PatchResourceResponder(resp) + result, err = client.UpdateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourceOperationsClient", "PatchResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.ArtifactSourcesClient", "Update", resp, "Failure responding to request") } return } -// PatchResourcePreparer prepares the PatchResource request. -func (client ArtifactSourceOperationsClient) PatchResourcePreparer(resourceGroupName string, labName string, name string, artifactSource ArtifactSource) (*http.Request, error) { +// UpdatePreparer prepares the Update request. +func (client ArtifactSourcesClient) UpdatePreparer(resourceGroupName string, labName string, name string, artifactSource ArtifactSourceFragment) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -365,8 +397,9 @@ func (client ArtifactSourceOperationsClient) PatchResourcePreparer(resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -379,15 +412,15 @@ func (client ArtifactSourceOperationsClient) PatchResourcePreparer(resourceGroup return preparer.Prepare(&http.Request{}) } -// PatchResourceSender sends the PatchResource request. The method will close the +// UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. -func (client ArtifactSourceOperationsClient) PatchResourceSender(req *http.Request) (*http.Response, error) { +func (client ArtifactSourcesClient) UpdateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// PatchResourceResponder handles the response to the PatchResource request. The method always +// UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client ArtifactSourceOperationsClient) PatchResourceResponder(resp *http.Response) (result ArtifactSource, err error) { +func (client ArtifactSourcesClient) UpdateResponder(resp *http.Response) (result ArtifactSource, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/arm/devtestlabs/client.go b/arm/devtestlabs/client.go index 44aad7b34d89..65e59fad0184 100644 --- a/arm/devtestlabs/client.go +++ b/arm/devtestlabs/client.go @@ -1,7 +1,7 @@ -// Package devtestlabs implements the Azure ARM Devtestlabs service API -// version 2016-05-15. +// Package devtestlabs implements the Azure ARM Devtestlabs service API version +// 2016-05-15. // -// Azure DevTest Labs REST API. +// The DevTest Labs Client. package devtestlabs // Copyright (c) Microsoft and contributors. All rights reserved. @@ -18,7 +18,7 @@ package devtestlabs // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Devtestlabs - APIVersion = "2016-05-15" - // DefaultBaseURI is the default URI used for the service Devtestlabs DefaultBaseURI = "https://management.azure.com" ) @@ -38,7 +35,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/arm/devtestlabs/costoperations.go b/arm/devtestlabs/costoperations.go deleted file mode 100644 index 79bfa1361027..000000000000 --- a/arm/devtestlabs/costoperations.go +++ /dev/null @@ -1,106 +0,0 @@ -package devtestlabs - -// Copyright (c) Microsoft and contributors. 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 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// CostOperationsClient is the azure DevTest Labs REST API. -type CostOperationsClient struct { - ManagementClient -} - -// NewCostOperationsClient creates an instance of the CostOperationsClient -// client. -func NewCostOperationsClient(subscriptionID string) CostOperationsClient { - return NewCostOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCostOperationsClientWithBaseURI creates an instance of the -// CostOperationsClient client. -func NewCostOperationsClientWithBaseURI(baseURI string, subscriptionID string) CostOperationsClient { - return CostOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// GetResource get cost. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the cost. -func (client CostOperationsClient) GetResource(resourceGroupName string, labName string, name string) (result Cost, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.CostOperationsClient", "GetResource", nil, "Failure preparing request") - } - - resp, err := client.GetResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.CostOperationsClient", "GetResource", resp, "Failure sending request") - } - - result, err = client.GetResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.CostOperationsClient", "GetResource", resp, "Failure responding to request") - } - - return -} - -// GetResourcePreparer prepares the GetResource request. -func (client CostOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetResourceSender sends the GetResource request. The method will close the -// http.Response Body if it receives an error. -func (client CostOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResourceResponder handles the response to the GetResource request. The method always -// closes the http.Response Body. -func (client CostOperationsClient) GetResourceResponder(resp *http.Response) (result Cost, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/arm/devtestlabs/costs.go b/arm/devtestlabs/costs.go new file mode 100644 index 000000000000..0e4dcc256615 --- /dev/null +++ b/arm/devtestlabs/costs.go @@ -0,0 +1,187 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CostsClient is the the DevTest Labs Client. +type CostsClient struct { + ManagementClient +} + +// NewCostsClient creates an instance of the CostsClient client. +func NewCostsClient(subscriptionID string) CostsClient { + return NewCostsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCostsClientWithBaseURI creates an instance of the CostsClient client. +func NewCostsClientWithBaseURI(baseURI string, subscriptionID string) CostsClient { + return CostsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing cost. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the cost. labCost is a cost item. +func (client CostsClient) CreateOrUpdate(resourceGroupName string, labName string, name string, labCost LabCost) (result LabCost, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: labCost, + Constraints: []validation.Constraint{{Target: "labCost.LabCostProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.CostsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, labCost) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CostsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.CostsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CostsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CostsClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, labCost LabCost) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}", pathParameters), + autorest.WithJSON(labCost), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CostsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CostsClient) CreateOrUpdateResponder(resp *http.Response) (result LabCost, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get cost. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the cost. expand is specify the $expand query. +// Example: 'properties($expand=labCostDetails)' +func (client CostsClient) Get(resourceGroupName string, labName string, name string, expand string) (result LabCost, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CostsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.CostsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CostsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CostsClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CostsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CostsClient) GetResponder(resp *http.Response) (result LabCost, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/customimageoperations.go b/arm/devtestlabs/customimageoperations.go deleted file mode 100644 index e32bbf95df03..000000000000 --- a/arm/devtestlabs/customimageoperations.go +++ /dev/null @@ -1,343 +0,0 @@ -package devtestlabs - -// Copyright (c) Microsoft and contributors. 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 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// CustomImageOperationsClient is the azure DevTest Labs REST API. -type CustomImageOperationsClient struct { - ManagementClient -} - -// NewCustomImageOperationsClient creates an instance of the -// CustomImageOperationsClient client. -func NewCustomImageOperationsClient(subscriptionID string) CustomImageOperationsClient { - return NewCustomImageOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCustomImageOperationsClientWithBaseURI creates an instance of the -// CustomImageOperationsClient client. -func NewCustomImageOperationsClientWithBaseURI(baseURI string, subscriptionID string) CustomImageOperationsClient { - return CustomImageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdateResource create or replace an existing custom image. This -// operation can take a while to complete. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the custom image. -func (client CustomImageOperationsClient) CreateOrUpdateResource(resourceGroupName string, labName string, name string, customImage CustomImage, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, labName, name, customImage, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "CreateOrUpdateResource", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "CreateOrUpdateResource", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "CreateOrUpdateResource", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client CustomImageOperationsClient) CreateOrUpdateResourcePreparer(resourceGroupName string, labName string, name string, customImage CustomImage, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}", pathParameters), - autorest.WithJSON(customImage), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the -// http.Response Body if it receives an error. -func (client CustomImageOperationsClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always -// closes the http.Response Body. -func (client CustomImageOperationsClient) CreateOrUpdateResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteResource delete custom image. This operation can take a while to -// complete. This method may poll for completion. Polling can be canceled by -// passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the custom image. -func (client CustomImageOperationsClient) DeleteResource(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, labName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "DeleteResource", nil, "Failure preparing request") - } - - resp, err := client.DeleteResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "DeleteResource", resp, "Failure sending request") - } - - result, err = client.DeleteResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "DeleteResource", resp, "Failure responding to request") - } - - return -} - -// DeleteResourcePreparer prepares the DeleteResource request. -func (client CustomImageOperationsClient) DeleteResourcePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// DeleteResourceSender sends the DeleteResource request. The method will close the -// http.Response Body if it receives an error. -func (client CustomImageOperationsClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// DeleteResourceResponder handles the response to the DeleteResource request. The method always -// closes the http.Response Body. -func (client CustomImageOperationsClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetResource get custom image. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the custom image. -func (client CustomImageOperationsClient) GetResource(resourceGroupName string, labName string, name string) (result CustomImage, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "GetResource", nil, "Failure preparing request") - } - - resp, err := client.GetResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "GetResource", resp, "Failure sending request") - } - - result, err = client.GetResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "GetResource", resp, "Failure responding to request") - } - - return -} - -// GetResourcePreparer prepares the GetResource request. -func (client CustomImageOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetResourceSender sends the GetResource request. The method will close the -// http.Response Body if it receives an error. -func (client CustomImageOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResourceResponder handles the response to the GetResource request. The method always -// closes the http.Response Body. -func (client CustomImageOperationsClient) GetResourceResponder(resp *http.Response) (result CustomImage, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list custom images in a given lab. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. filter is the filter to apply on the operation. top is the -// maximum number of resources to return from the operation. orderBy is the -// ordering expression for the results, using OData notation. -func (client CustomImageOperationsClient) List(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationCustomImage, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderBy) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "List", nil, "Failure preparing request") - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "List", resp, "Failure sending request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client CustomImageOperationsClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client CustomImageOperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client CustomImageOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationCustomImage, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNextResults retrieves the next set of results, if any. -func (client CustomImageOperationsClient) ListNextResults(lastResults ResponseWithContinuationCustomImage) (result ResponseWithContinuationCustomImage, err error) { - req, err := lastResults.ResponseWithContinuationCustomImagePreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "List", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "List", resp, "Failure sending next results request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.CustomImageOperationsClient", "List", resp, "Failure responding to next results request") - } - - return -} diff --git a/arm/devtestlabs/customimages.go b/arm/devtestlabs/customimages.go new file mode 100644 index 000000000000..7cfdd5715c05 --- /dev/null +++ b/arm/devtestlabs/customimages.go @@ -0,0 +1,395 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CustomImagesClient is the the DevTest Labs Client. +type CustomImagesClient struct { + ManagementClient +} + +// NewCustomImagesClient creates an instance of the CustomImagesClient client. +func NewCustomImagesClient(subscriptionID string) CustomImagesClient { + return NewCustomImagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCustomImagesClientWithBaseURI creates an instance of the +// CustomImagesClient client. +func NewCustomImagesClientWithBaseURI(baseURI string, subscriptionID string) CustomImagesClient { + return CustomImagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing custom image. This operation +// can take a while to complete. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the custom image. customImage is a custom +// image. +func (client CustomImagesClient) CreateOrUpdate(resourceGroupName string, labName string, name string, customImage CustomImage, cancel <-chan struct{}) (<-chan CustomImage, <-chan error) { + resultChan := make(chan CustomImage, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: customImage, + Constraints: []validation.Constraint{{Target: "customImage.CustomImageProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "devtestlabs.CustomImagesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result CustomImage + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, customImage, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CustomImagesClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, customImage CustomImage, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}", pathParameters), + autorest.WithJSON(customImage), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CustomImagesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CustomImagesClient) CreateOrUpdateResponder(resp *http.Response) (result CustomImage, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete custom image. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the custom image. +func (client CustomImagesClient) Delete(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client CustomImagesClient) DeletePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CustomImagesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CustomImagesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get custom image. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the custom image. expand is specify the $expand +// query. Example: 'properties($select=vm)' +func (client CustomImagesClient) Get(resourceGroupName string, labName string, name string, expand string) (result CustomImage, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CustomImagesClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CustomImagesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CustomImagesClient) GetResponder(resp *http.Response) (result CustomImage, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list custom images in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. expand is specify the $expand query. Example: +// 'properties($select=vm)' filter is the filter to apply to the operation. top +// is the maximum number of resources to return from the operation. orderby is +// the ordering expression for the results, using OData notation. +func (client CustomImagesClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationCustomImage, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client CustomImagesClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/customimages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client CustomImagesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CustomImagesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationCustomImage, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client CustomImagesClient) ListNextResults(lastResults ResponseWithContinuationCustomImage) (result ResponseWithContinuationCustomImage, err error) { + req, err := lastResults.ResponseWithContinuationCustomImagePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.CustomImagesClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/devtestlabs/disks.go b/arm/devtestlabs/disks.go new file mode 100644 index 000000000000..6cf3809334b0 --- /dev/null +++ b/arm/devtestlabs/disks.go @@ -0,0 +1,574 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DisksClient is the the DevTest Labs Client. +type DisksClient struct { + ManagementClient +} + +// NewDisksClient creates an instance of the DisksClient client. +func NewDisksClient(subscriptionID string) DisksClient { + return NewDisksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDisksClientWithBaseURI creates an instance of the DisksClient client. +func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClient { + return DisksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Attach attach and create the lease of the disk to the virtual machine. This +// operation can take a while to complete. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// disk. attachDiskProperties is properties of the disk to attach. +func (client DisksClient) Attach(resourceGroupName string, labName string, userName string, name string, attachDiskProperties AttachDiskProperties, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.AttachPreparer(resourceGroupName, labName, userName, name, attachDiskProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Attach", nil, "Failure preparing request") + return + } + + resp, err := client.AttachSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Attach", resp, "Failure sending request") + return + } + + result, err = client.AttachResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Attach", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// AttachPreparer prepares the Attach request. +func (client DisksClient) AttachPreparer(resourceGroupName string, labName string, userName string, name string, attachDiskProperties AttachDiskProperties, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach", pathParameters), + autorest.WithJSON(attachDiskProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// AttachSender sends the Attach request. The method will close the +// http.Response Body if it receives an error. +func (client DisksClient) AttachSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// AttachResponder handles the response to the Attach request. The method always +// closes the http.Response Body. +func (client DisksClient) AttachResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate create or replace an existing disk. This operation can take a +// while to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// disk. disk is a Disk. +func (client DisksClient) CreateOrUpdate(resourceGroupName string, labName string, userName string, name string, disk Disk, cancel <-chan struct{}) (<-chan Disk, <-chan error) { + resultChan := make(chan Disk, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: disk, + Constraints: []validation.Constraint{{Target: "disk.DiskProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "devtestlabs.DisksClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Disk + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, userName, name, disk, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DisksClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, userName string, name string, disk Disk, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}", pathParameters), + autorest.WithJSON(disk), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DisksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result Disk, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete disk. This operation can take a while to complete. This method +// may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// disk. +func (client DisksClient) Delete(resourceGroupName string, labName string, userName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, labName, userName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client DisksClient) DeletePreparer(resourceGroupName string, labName string, userName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DisksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Detach detach and break the lease of the disk attached to the virtual +// machine. This operation can take a while to complete. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// disk. detachDiskProperties is properties of the disk to detach. +func (client DisksClient) Detach(resourceGroupName string, labName string, userName string, name string, detachDiskProperties DetachDiskProperties, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DetachPreparer(resourceGroupName, labName, userName, name, detachDiskProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Detach", nil, "Failure preparing request") + return + } + + resp, err := client.DetachSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Detach", resp, "Failure sending request") + return + } + + result, err = client.DetachResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Detach", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DetachPreparer prepares the Detach request. +func (client DisksClient) DetachPreparer(resourceGroupName string, labName string, userName string, name string, detachDiskProperties DetachDiskProperties, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach", pathParameters), + autorest.WithJSON(detachDiskProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DetachSender sends the Detach request. The method will close the +// http.Response Body if it receives an error. +func (client DisksClient) DetachSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DetachResponder handles the response to the Detach request. The method always +// closes the http.Response Body. +func (client DisksClient) DetachResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get disk. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// disk. expand is specify the $expand query. Example: +// 'properties($select=diskType)' +func (client DisksClient) Get(resourceGroupName string, labName string, userName string, name string, expand string) (result Disk, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, userName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DisksClient) GetPreparer(resourceGroupName string, labName string, userName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DisksClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DisksClient) GetResponder(resp *http.Response) (result Disk, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list disks in a given user profile. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. expand is specify the +// $expand query. Example: 'properties($select=diskType)' filter is the filter +// to apply to the operation. top is the maximum number of resources to return +// from the operation. orderby is the ordering expression for the results, +// using OData notation. +func (client DisksClient) List(resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationDisk, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, userName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client DisksClient) ListPreparer(resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DisksClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DisksClient) ListResponder(resp *http.Response) (result ResponseWithContinuationDisk, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client DisksClient) ListNextResults(lastResults ResponseWithContinuationDisk) (result ResponseWithContinuationDisk, err error) { + req, err := lastResults.ResponseWithContinuationDiskPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.DisksClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/devtestlabs/environments.go b/arm/devtestlabs/environments.go new file mode 100644 index 000000000000..ee5f41fe725c --- /dev/null +++ b/arm/devtestlabs/environments.go @@ -0,0 +1,403 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// EnvironmentsClient is the the DevTest Labs Client. +type EnvironmentsClient struct { + ManagementClient +} + +// NewEnvironmentsClient creates an instance of the EnvironmentsClient client. +func NewEnvironmentsClient(subscriptionID string) EnvironmentsClient { + return NewEnvironmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEnvironmentsClientWithBaseURI creates an instance of the +// EnvironmentsClient client. +func NewEnvironmentsClientWithBaseURI(baseURI string, subscriptionID string) EnvironmentsClient { + return EnvironmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing environment. This operation can +// take a while to complete. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be used +// to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// environment. dtlEnvironment is an environment, which is essentially an ARM +// template deployment. +func (client EnvironmentsClient) CreateOrUpdate(resourceGroupName string, labName string, userName string, name string, dtlEnvironment DtlEnvironment, cancel <-chan struct{}) (<-chan DtlEnvironment, <-chan error) { + resultChan := make(chan DtlEnvironment, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: dtlEnvironment, + Constraints: []validation.Constraint{{Target: "dtlEnvironment.EnvironmentProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "devtestlabs.EnvironmentsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result DtlEnvironment + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, userName, name, dtlEnvironment, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client EnvironmentsClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, userName string, name string, dtlEnvironment DtlEnvironment, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}", pathParameters), + autorest.WithJSON(dtlEnvironment), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client EnvironmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client EnvironmentsClient) CreateOrUpdateResponder(resp *http.Response) (result DtlEnvironment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete environment. This operation can take a while to complete. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// environment. +func (client EnvironmentsClient) Delete(resourceGroupName string, labName string, userName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, labName, userName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client EnvironmentsClient) DeletePreparer(resourceGroupName string, labName string, userName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client EnvironmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client EnvironmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get environment. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// environment. expand is specify the $expand query. Example: +// 'properties($select=deploymentProperties)' +func (client EnvironmentsClient) Get(resourceGroupName string, labName string, userName string, name string, expand string) (result DtlEnvironment, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, userName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client EnvironmentsClient) GetPreparer(resourceGroupName string, labName string, userName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client EnvironmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EnvironmentsClient) GetResponder(resp *http.Response) (result DtlEnvironment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list environments in a given user profile. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. expand is specify the +// $expand query. Example: 'properties($select=deploymentProperties)' filter is +// the filter to apply to the operation. top is the maximum number of resources +// to return from the operation. orderby is the ordering expression for the +// results, using OData notation. +func (client EnvironmentsClient) List(resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationDtlEnvironment, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, userName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client EnvironmentsClient) ListPreparer(resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/environments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client EnvironmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client EnvironmentsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationDtlEnvironment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client EnvironmentsClient) ListNextResults(lastResults ResponseWithContinuationDtlEnvironment) (result ResponseWithContinuationDtlEnvironment, err error) { + req, err := lastResults.ResponseWithContinuationDtlEnvironmentPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.EnvironmentsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/devtestlabs/formulaoperations.go b/arm/devtestlabs/formulaoperations.go deleted file mode 100644 index 2521bfd0854e..000000000000 --- a/arm/devtestlabs/formulaoperations.go +++ /dev/null @@ -1,338 +0,0 @@ -package devtestlabs - -// Copyright (c) Microsoft and contributors. 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 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// FormulaOperationsClient is the azure DevTest Labs REST API. -type FormulaOperationsClient struct { - ManagementClient -} - -// NewFormulaOperationsClient creates an instance of the -// FormulaOperationsClient client. -func NewFormulaOperationsClient(subscriptionID string) FormulaOperationsClient { - return NewFormulaOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewFormulaOperationsClientWithBaseURI creates an instance of the -// FormulaOperationsClient client. -func NewFormulaOperationsClientWithBaseURI(baseURI string, subscriptionID string) FormulaOperationsClient { - return FormulaOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdateResource create or replace an existing Formula. This -// operation can take a while to complete. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the formula. -func (client FormulaOperationsClient) CreateOrUpdateResource(resourceGroupName string, labName string, name string, formula Formula, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, labName, name, formula, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "CreateOrUpdateResource", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "CreateOrUpdateResource", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "CreateOrUpdateResource", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client FormulaOperationsClient) CreateOrUpdateResourcePreparer(resourceGroupName string, labName string, name string, formula Formula, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}", pathParameters), - autorest.WithJSON(formula), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the -// http.Response Body if it receives an error. -func (client FormulaOperationsClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always -// closes the http.Response Body. -func (client FormulaOperationsClient) CreateOrUpdateResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteResource delete formula. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the formula. -func (client FormulaOperationsClient) DeleteResource(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "DeleteResource", nil, "Failure preparing request") - } - - resp, err := client.DeleteResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "DeleteResource", resp, "Failure sending request") - } - - result, err = client.DeleteResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "DeleteResource", resp, "Failure responding to request") - } - - return -} - -// DeleteResourcePreparer prepares the DeleteResource request. -func (client FormulaOperationsClient) DeleteResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// DeleteResourceSender sends the DeleteResource request. The method will close the -// http.Response Body if it receives an error. -func (client FormulaOperationsClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// DeleteResourceResponder handles the response to the DeleteResource request. The method always -// closes the http.Response Body. -func (client FormulaOperationsClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetResource get formula. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the formula. -func (client FormulaOperationsClient) GetResource(resourceGroupName string, labName string, name string) (result Formula, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "GetResource", nil, "Failure preparing request") - } - - resp, err := client.GetResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "GetResource", resp, "Failure sending request") - } - - result, err = client.GetResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "GetResource", resp, "Failure responding to request") - } - - return -} - -// GetResourcePreparer prepares the GetResource request. -func (client FormulaOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetResourceSender sends the GetResource request. The method will close the -// http.Response Body if it receives an error. -func (client FormulaOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResourceResponder handles the response to the GetResource request. The method always -// closes the http.Response Body. -func (client FormulaOperationsClient) GetResourceResponder(resp *http.Response) (result Formula, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list formulas in a given lab. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. filter is the filter to apply on the operation. top is the -// maximum number of resources to return from the operation. orderBy is the -// ordering expression for the results, using OData notation. -func (client FormulaOperationsClient) List(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationFormula, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderBy) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "List", nil, "Failure preparing request") - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "List", resp, "Failure sending request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client FormulaOperationsClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client FormulaOperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client FormulaOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationFormula, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNextResults retrieves the next set of results, if any. -func (client FormulaOperationsClient) ListNextResults(lastResults ResponseWithContinuationFormula) (result ResponseWithContinuationFormula, err error) { - req, err := lastResults.ResponseWithContinuationFormulaPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "List", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "List", resp, "Failure sending next results request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.FormulaOperationsClient", "List", resp, "Failure responding to next results request") - } - - return -} diff --git a/arm/devtestlabs/formulas.go b/arm/devtestlabs/formulas.go new file mode 100644 index 000000000000..9c85729216d6 --- /dev/null +++ b/arm/devtestlabs/formulas.go @@ -0,0 +1,393 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FormulasClient is the the DevTest Labs Client. +type FormulasClient struct { + ManagementClient +} + +// NewFormulasClient creates an instance of the FormulasClient client. +func NewFormulasClient(subscriptionID string) FormulasClient { + return NewFormulasClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFormulasClientWithBaseURI creates an instance of the FormulasClient +// client. +func NewFormulasClientWithBaseURI(baseURI string, subscriptionID string) FormulasClient { + return FormulasClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing Formula. This operation can +// take a while to complete. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be used +// to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the formula. formula is a formula for creating +// a VM, specifying an image base and other parameters +func (client FormulasClient) CreateOrUpdate(resourceGroupName string, labName string, name string, formula Formula, cancel <-chan struct{}) (<-chan Formula, <-chan error) { + resultChan := make(chan Formula, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: formula, + Constraints: []validation.Constraint{{Target: "formula.FormulaProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "formula.FormulaProperties.FormulaContent", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "formula.FormulaProperties.FormulaContent.LabVirtualMachineCreationParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "formula.FormulaProperties.FormulaContent.LabVirtualMachineCreationParameterProperties.ApplicableSchedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "formula.FormulaProperties.FormulaContent.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "formula.FormulaProperties.FormulaContent.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "formula.FormulaProperties.FormulaContent.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "formula.FormulaProperties.FormulaContent.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "formula.FormulaProperties.FormulaContent.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "devtestlabs.FormulasClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Formula + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, formula, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FormulasClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, formula Formula, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}", pathParameters), + autorest.WithJSON(formula), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FormulasClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FormulasClient) CreateOrUpdateResponder(resp *http.Response) (result Formula, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete formula. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the formula. +func (client FormulasClient) Delete(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FormulasClient) DeletePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FormulasClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FormulasClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get formula. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the formula. expand is specify the $expand +// query. Example: 'properties($select=description)' +func (client FormulasClient) Get(resourceGroupName string, labName string, name string, expand string) (result Formula, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FormulasClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FormulasClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FormulasClient) GetResponder(resp *http.Response) (result Formula, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list formulas in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. expand is specify the $expand query. Example: +// 'properties($select=description)' filter is the filter to apply to the +// operation. top is the maximum number of resources to return from the +// operation. orderby is the ordering expression for the results, using OData +// notation. +func (client FormulasClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationFormula, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client FormulasClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client FormulasClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client FormulasClient) ListResponder(resp *http.Response) (result ResponseWithContinuationFormula, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client FormulasClient) ListNextResults(lastResults ResponseWithContinuationFormula) (result ResponseWithContinuationFormula, err error) { + req, err := lastResults.ResponseWithContinuationFormulaPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.FormulasClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/devtestlabs/galleryimageoperations.go b/arm/devtestlabs/galleryimages.go similarity index 55% rename from arm/devtestlabs/galleryimageoperations.go rename to arm/devtestlabs/galleryimages.go index 031353c401ac..16df40fb45e4 100644 --- a/arm/devtestlabs/galleryimageoperations.go +++ b/arm/devtestlabs/galleryimages.go @@ -14,7 +14,7 @@ package devtestlabs // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,59 +24,66 @@ import ( "net/http" ) -// GalleryImageOperationsClient is the azure DevTest Labs REST API. -type GalleryImageOperationsClient struct { +// GalleryImagesClient is the the DevTest Labs Client. +type GalleryImagesClient struct { ManagementClient } -// NewGalleryImageOperationsClient creates an instance of the -// GalleryImageOperationsClient client. -func NewGalleryImageOperationsClient(subscriptionID string) GalleryImageOperationsClient { - return NewGalleryImageOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +// NewGalleryImagesClient creates an instance of the GalleryImagesClient +// client. +func NewGalleryImagesClient(subscriptionID string) GalleryImagesClient { + return NewGalleryImagesClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewGalleryImageOperationsClientWithBaseURI creates an instance of the -// GalleryImageOperationsClient client. -func NewGalleryImageOperationsClientWithBaseURI(baseURI string, subscriptionID string) GalleryImageOperationsClient { - return GalleryImageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +// NewGalleryImagesClientWithBaseURI creates an instance of the +// GalleryImagesClient client. +func NewGalleryImagesClientWithBaseURI(baseURI string, subscriptionID string) GalleryImagesClient { + return GalleryImagesClient{NewWithBaseURI(baseURI, subscriptionID)} } // List list gallery images in a given lab. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. filter is the filter to apply on the operation. top is the -// maximum number of resources to return from the operation. orderBy is the -// ordering expression for the results, using OData notation. -func (client GalleryImageOperationsClient) List(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationGalleryImage, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderBy) +// the lab. expand is specify the $expand query. Example: +// 'properties($select=author)' filter is the filter to apply to the operation. +// top is the maximum number of resources to return from the operation. orderby +// is the ordering expression for the results, using OData notation. +func (client GalleryImagesClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationGalleryImage, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.GalleryImageOperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.GalleryImagesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.GalleryImageOperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.GalleryImagesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.GalleryImageOperationsClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.GalleryImagesClient", "List", resp, "Failure responding to request") } return } // ListPreparer prepares the List request. -func (client GalleryImageOperationsClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) { +func (client GalleryImagesClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -84,8 +91,8 @@ func (client GalleryImageOperationsClient) ListPreparer(resourceGroupName string if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) } preparer := autorest.CreatePreparer( @@ -98,13 +105,13 @@ func (client GalleryImageOperationsClient) ListPreparer(resourceGroupName string // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client GalleryImageOperationsClient) ListSender(req *http.Request) (*http.Response, error) { +func (client GalleryImagesClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client GalleryImageOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationGalleryImage, err error) { +func (client GalleryImagesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationGalleryImage, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -116,10 +123,10 @@ func (client GalleryImageOperationsClient) ListResponder(resp *http.Response) (r } // ListNextResults retrieves the next set of results, if any. -func (client GalleryImageOperationsClient) ListNextResults(lastResults ResponseWithContinuationGalleryImage) (result ResponseWithContinuationGalleryImage, err error) { +func (client GalleryImagesClient) ListNextResults(lastResults ResponseWithContinuationGalleryImage) (result ResponseWithContinuationGalleryImage, err error) { req, err := lastResults.ResponseWithContinuationGalleryImagePreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.GalleryImageOperationsClient", "List", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.GalleryImagesClient", "List", nil, "Failure preparing next results request") } if req == nil { return @@ -128,12 +135,12 @@ func (client GalleryImageOperationsClient) ListNextResults(lastResults ResponseW resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.GalleryImageOperationsClient", "List", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.GalleryImagesClient", "List", resp, "Failure sending next results request") } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.GalleryImageOperationsClient", "List", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "devtestlabs.GalleryImagesClient", "List", resp, "Failure responding to next results request") } return diff --git a/arm/devtestlabs/globalschedules.go b/arm/devtestlabs/globalschedules.go new file mode 100644 index 000000000000..8c5b5d0761ba --- /dev/null +++ b/arm/devtestlabs/globalschedules.go @@ -0,0 +1,691 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// GlobalSchedulesClient is the the DevTest Labs Client. +type GlobalSchedulesClient struct { + ManagementClient +} + +// NewGlobalSchedulesClient creates an instance of the GlobalSchedulesClient +// client. +func NewGlobalSchedulesClient(subscriptionID string) GlobalSchedulesClient { + return NewGlobalSchedulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGlobalSchedulesClientWithBaseURI creates an instance of the +// GlobalSchedulesClient client. +func NewGlobalSchedulesClientWithBaseURI(baseURI string, subscriptionID string) GlobalSchedulesClient { + return GlobalSchedulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing schedule. +// +// resourceGroupName is the name of the resource group. name is the name of the +// schedule. schedule is a schedule. +func (client GlobalSchedulesClient) CreateOrUpdate(resourceGroupName string, name string, schedule Schedule) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: schedule, + Constraints: []validation.Constraint{{Target: "schedule.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.GlobalSchedulesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, schedule) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GlobalSchedulesClient) CreateOrUpdatePreparer(resourceGroupName string, name string, schedule Schedule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}", pathParameters), + autorest.WithJSON(schedule), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) CreateOrUpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete schedule. +// +// resourceGroupName is the name of the resource group. name is the name of the +// schedule. +func (client GlobalSchedulesClient) Delete(resourceGroupName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GlobalSchedulesClient) DeletePreparer(resourceGroupName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Execute execute a schedule. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. name is the name of the +// schedule. +func (client GlobalSchedulesClient) Execute(resourceGroupName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ExecutePreparer(resourceGroupName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Execute", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ExecutePreparer prepares the Execute request. +func (client GlobalSchedulesClient) ExecutePreparer(resourceGroupName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/execute", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get schedule. +// +// resourceGroupName is the name of the resource group. name is the name of the +// schedule. expand is specify the $expand query. Example: +// 'properties($select=status)' +func (client GlobalSchedulesClient) Get(resourceGroupName string, name string, expand string) (result Schedule, err error) { + req, err := client.GetPreparer(resourceGroupName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client GlobalSchedulesClient) GetPreparer(resourceGroupName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) GetResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list schedules in a resource group. +// +// resourceGroupName is the name of the resource group. expand is specify the +// $expand query. Example: 'properties($select=status)' filter is the filter to +// apply to the operation. top is the maximum number of resources to return +// from the operation. orderby is the ordering expression for the results, +// using OData notation. +func (client GlobalSchedulesClient) ListByResourceGroup(resourceGroupName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationSchedule, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client GlobalSchedulesClient) ListByResourceGroupPreparer(resourceGroupName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) ListByResourceGroupResponder(resp *http.Response) (result ResponseWithContinuationSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client GlobalSchedulesClient) ListByResourceGroupNextResults(lastResults ResponseWithContinuationSchedule) (result ResponseWithContinuationSchedule, err error) { + req, err := lastResults.ResponseWithContinuationSchedulePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// ListBySubscription list schedules in a subscription. +// +// expand is specify the $expand query. Example: 'properties($select=status)' +// filter is the filter to apply to the operation. top is the maximum number of +// resources to return from the operation. orderby is the ordering expression +// for the results, using OData notation. +func (client GlobalSchedulesClient) ListBySubscription(expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationSchedule, err error) { + req, err := client.ListBySubscriptionPreparer(expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client GlobalSchedulesClient) ListBySubscriptionPreparer(expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/schedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) ListBySubscriptionResponder(resp *http.Response) (result ResponseWithContinuationSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionNextResults retrieves the next set of results, if any. +func (client GlobalSchedulesClient) ListBySubscriptionNextResults(lastResults ResponseWithContinuationSchedule) (result ResponseWithContinuationSchedule, err error) { + req, err := lastResults.ResponseWithContinuationSchedulePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListBySubscription", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListBySubscription", resp, "Failure sending next results request") + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "ListBySubscription", resp, "Failure responding to next results request") + } + + return +} + +// Retarget updates a schedule's target resource Id. This operation can take a +// while to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. name is the name of the +// schedule. retargetScheduleProperties is properties for retargeting a virtual +// machine schedule. +func (client GlobalSchedulesClient) Retarget(resourceGroupName string, name string, retargetScheduleProperties RetargetScheduleProperties, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RetargetPreparer(resourceGroupName, name, retargetScheduleProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Retarget", nil, "Failure preparing request") + return + } + + resp, err := client.RetargetSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Retarget", resp, "Failure sending request") + return + } + + result, err = client.RetargetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Retarget", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// RetargetPreparer prepares the Retarget request. +func (client GlobalSchedulesClient) RetargetPreparer(resourceGroupName string, name string, retargetScheduleProperties RetargetScheduleProperties, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}/retarget", pathParameters), + autorest.WithJSON(retargetScheduleProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RetargetSender sends the Retarget request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) RetargetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RetargetResponder handles the response to the Retarget request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) RetargetResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update modify properties of schedules. +// +// resourceGroupName is the name of the resource group. name is the name of the +// schedule. schedule is a schedule. +func (client GlobalSchedulesClient) Update(resourceGroupName string, name string, schedule ScheduleFragment) (result Schedule, err error) { + req, err := client.UpdatePreparer(resourceGroupName, name, schedule) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.GlobalSchedulesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client GlobalSchedulesClient) UpdatePreparer(resourceGroupName string, name string, schedule ScheduleFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/schedules/{name}", pathParameters), + autorest.WithJSON(schedule), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client GlobalSchedulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client GlobalSchedulesClient) UpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/laboperations.go b/arm/devtestlabs/laboperations.go deleted file mode 100644 index 052c99ec9f55..000000000000 --- a/arm/devtestlabs/laboperations.go +++ /dev/null @@ -1,719 +0,0 @@ -package devtestlabs - -// Copyright (c) Microsoft and contributors. 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 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// LabOperationsClient is the azure DevTest Labs REST API. -type LabOperationsClient struct { - ManagementClient -} - -// NewLabOperationsClient creates an instance of the LabOperationsClient -// client. -func NewLabOperationsClient(subscriptionID string) LabOperationsClient { - return NewLabOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewLabOperationsClientWithBaseURI creates an instance of the -// LabOperationsClient client. -func NewLabOperationsClientWithBaseURI(baseURI string, subscriptionID string) LabOperationsClient { - return LabOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateEnvironment create virtual machines in a Lab. This operation can take -// a while to complete. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. name is the name of -// the lab. -func (client LabOperationsClient) CreateEnvironment(resourceGroupName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateEnvironmentPreparer(resourceGroupName, name, labVirtualMachine, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "CreateEnvironment", nil, "Failure preparing request") - } - - resp, err := client.CreateEnvironmentSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "CreateEnvironment", resp, "Failure sending request") - } - - result, err = client.CreateEnvironmentResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "CreateEnvironment", resp, "Failure responding to request") - } - - return -} - -// CreateEnvironmentPreparer prepares the CreateEnvironment request. -func (client LabOperationsClient) CreateEnvironmentPreparer(resourceGroupName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment", pathParameters), - autorest.WithJSON(labVirtualMachine), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// CreateEnvironmentSender sends the CreateEnvironment request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) CreateEnvironmentSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// CreateEnvironmentResponder handles the response to the CreateEnvironment request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) CreateEnvironmentResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateOrUpdateResource create or replace an existing Lab. This operation -// can take a while to complete. This method may poll for completion. Polling -// can be canceled by passing the cancel channel argument. The channel will -// be used to cancel polling and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. name is the name of -// the lab. -func (client LabOperationsClient) CreateOrUpdateResource(resourceGroupName string, name string, lab Lab, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, name, lab, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "CreateOrUpdateResource", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "CreateOrUpdateResource", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "CreateOrUpdateResource", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client LabOperationsClient) CreateOrUpdateResourcePreparer(resourceGroupName string, name string, lab Lab, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), - autorest.WithJSON(lab), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) CreateOrUpdateResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteResource delete lab. This operation can take a while to complete. -// This method may poll for completion. Polling can be canceled by passing -// the cancel channel argument. The channel will be used to cancel polling -// and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. name is the name of -// the lab. -func (client LabOperationsClient) DeleteResource(resourceGroupName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "DeleteResource", nil, "Failure preparing request") - } - - resp, err := client.DeleteResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "DeleteResource", resp, "Failure sending request") - } - - result, err = client.DeleteResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "DeleteResource", resp, "Failure responding to request") - } - - return -} - -// DeleteResourcePreparer prepares the DeleteResource request. -func (client LabOperationsClient) DeleteResourcePreparer(resourceGroupName string, name string, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// DeleteResourceSender sends the DeleteResource request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// DeleteResourceResponder handles the response to the DeleteResource request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GenerateUploadURI generate a URI for uploading custom disk images to a Lab. -// -// resourceGroupName is the name of the resource group. name is the name of -// the lab. -func (client LabOperationsClient) GenerateUploadURI(resourceGroupName string, name string, generateUploadURIParameter GenerateUploadURIParameter) (result GenerateUploadURIResponse, err error) { - req, err := client.GenerateUploadURIPreparer(resourceGroupName, name, generateUploadURIParameter) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "GenerateUploadURI", nil, "Failure preparing request") - } - - resp, err := client.GenerateUploadURISender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "GenerateUploadURI", resp, "Failure sending request") - } - - result, err = client.GenerateUploadURIResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "GenerateUploadURI", resp, "Failure responding to request") - } - - return -} - -// GenerateUploadURIPreparer prepares the GenerateUploadURI request. -func (client LabOperationsClient) GenerateUploadURIPreparer(resourceGroupName string, name string, generateUploadURIParameter GenerateUploadURIParameter) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/generateUploadUri", pathParameters), - autorest.WithJSON(generateUploadURIParameter), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GenerateUploadURISender sends the GenerateUploadURI request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) GenerateUploadURISender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GenerateUploadURIResponder handles the response to the GenerateUploadURI request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) GenerateUploadURIResponder(resp *http.Response) (result GenerateUploadURIResponse, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetResource get lab. -// -// resourceGroupName is the name of the resource group. name is the name of -// the lab. -func (client LabOperationsClient) GetResource(resourceGroupName string, name string) (result Lab, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "GetResource", nil, "Failure preparing request") - } - - resp, err := client.GetResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "GetResource", resp, "Failure sending request") - } - - result, err = client.GetResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "GetResource", resp, "Failure responding to request") - } - - return -} - -// GetResourcePreparer prepares the GetResource request. -func (client LabOperationsClient) GetResourcePreparer(resourceGroupName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetResourceSender sends the GetResource request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResourceResponder handles the response to the GetResource request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) GetResourceResponder(resp *http.Response) (result Lab, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByResourceGroup list labs in a resource group. -// -// resourceGroupName is the name of the resource group. filter is the filter -// to apply on the operation. top is the maximum number of resources to -// return from the operation. orderBy is the ordering expression for the -// results, using OData notation. -func (client LabOperationsClient) ListByResourceGroup(resourceGroupName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationLab, err error) { - req, err := client.ListByResourceGroupPreparer(resourceGroupName, filter, top, orderBy) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListByResourceGroup", nil, "Failure preparing request") - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListByResourceGroup", resp, "Failure sending request") - } - - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListByResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client LabOperationsClient) ListByResourceGroupPreparer(resourceGroupName string, filter string, top *int32, orderBy string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) ListByResourceGroupResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByResourceGroupNextResults retrieves the next set of results, if any. -func (client LabOperationsClient) ListByResourceGroupNextResults(lastResults ResponseWithContinuationLab) (result ResponseWithContinuationLab, err error) { - req, err := lastResults.ResponseWithContinuationLabPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListByResourceGroup", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListByResourceGroup", resp, "Failure sending next results request") - } - - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListByResourceGroup", resp, "Failure responding to next results request") - } - - return -} - -// ListBySubscription list labs in a subscription. -// -// filter is the filter to apply on the operation. top is the maximum number -// of resources to return from the operation. orderBy is the ordering -// expression for the results, using OData notation. -func (client LabOperationsClient) ListBySubscription(filter string, top *int32, orderBy string) (result ResponseWithContinuationLab, err error) { - req, err := client.ListBySubscriptionPreparer(filter, top, orderBy) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListBySubscription", nil, "Failure preparing request") - } - - resp, err := client.ListBySubscriptionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListBySubscription", resp, "Failure sending request") - } - - result, err = client.ListBySubscriptionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListBySubscription", resp, "Failure responding to request") - } - - return -} - -// ListBySubscriptionPreparer prepares the ListBySubscription request. -func (client LabOperationsClient) ListBySubscriptionPreparer(filter string, top *int32, orderBy string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/labs", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListBySubscriptionSender sends the ListBySubscription request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) ListBySubscriptionResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListBySubscriptionNextResults retrieves the next set of results, if any. -func (client LabOperationsClient) ListBySubscriptionNextResults(lastResults ResponseWithContinuationLab) (result ResponseWithContinuationLab, err error) { - req, err := lastResults.ResponseWithContinuationLabPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListBySubscription", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListBySubscriptionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListBySubscription", resp, "Failure sending next results request") - } - - result, err = client.ListBySubscriptionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListBySubscription", resp, "Failure responding to next results request") - } - - return -} - -// ListVhds list disk images available for custom image creation. -// -// resourceGroupName is the name of the resource group. name is the name of -// the lab. -func (client LabOperationsClient) ListVhds(resourceGroupName string, name string) (result ResponseWithContinuationLabVhd, err error) { - req, err := client.ListVhdsPreparer(resourceGroupName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListVhds", nil, "Failure preparing request") - } - - resp, err := client.ListVhdsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListVhds", resp, "Failure sending request") - } - - result, err = client.ListVhdsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListVhds", resp, "Failure responding to request") - } - - return -} - -// ListVhdsPreparer prepares the ListVhds request. -func (client LabOperationsClient) ListVhdsPreparer(resourceGroupName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/listVhds", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListVhdsSender sends the ListVhds request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) ListVhdsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListVhdsResponder handles the response to the ListVhds request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) ListVhdsResponder(resp *http.Response) (result ResponseWithContinuationLabVhd, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListVhdsNextResults retrieves the next set of results, if any. -func (client LabOperationsClient) ListVhdsNextResults(lastResults ResponseWithContinuationLabVhd) (result ResponseWithContinuationLabVhd, err error) { - req, err := lastResults.ResponseWithContinuationLabVhdPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListVhds", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListVhdsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListVhds", resp, "Failure sending next results request") - } - - result, err = client.ListVhdsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "ListVhds", resp, "Failure responding to next results request") - } - - return -} - -// PatchResource modify properties of labs. -// -// resourceGroupName is the name of the resource group. name is the name of -// the lab. -func (client LabOperationsClient) PatchResource(resourceGroupName string, name string, lab Lab) (result Lab, err error) { - req, err := client.PatchResourcePreparer(resourceGroupName, name, lab) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "PatchResource", nil, "Failure preparing request") - } - - resp, err := client.PatchResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "PatchResource", resp, "Failure sending request") - } - - result, err = client.PatchResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.LabOperationsClient", "PatchResource", resp, "Failure responding to request") - } - - return -} - -// PatchResourcePreparer prepares the PatchResource request. -func (client LabOperationsClient) PatchResourcePreparer(resourceGroupName string, name string, lab Lab) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), - autorest.WithJSON(lab), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// PatchResourceSender sends the PatchResource request. The method will close the -// http.Response Body if it receives an error. -func (client LabOperationsClient) PatchResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// PatchResourceResponder handles the response to the PatchResource request. The method always -// closes the http.Response Body. -func (client LabOperationsClient) PatchResourceResponder(resp *http.Response) (result Lab, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/arm/devtestlabs/labs.go b/arm/devtestlabs/labs.go new file mode 100644 index 000000000000..0ed14dabb55c --- /dev/null +++ b/arm/devtestlabs/labs.go @@ -0,0 +1,977 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// LabsClient is the the DevTest Labs Client. +type LabsClient struct { + ManagementClient +} + +// NewLabsClient creates an instance of the LabsClient client. +func NewLabsClient(subscriptionID string) LabsClient { + return NewLabsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLabsClientWithBaseURI creates an instance of the LabsClient client. +func NewLabsClientWithBaseURI(baseURI string, subscriptionID string) LabsClient { + return LabsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ClaimAnyVM claim a random claimable virtual machine in the lab. This +// operation can take a while to complete. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. +func (client LabsClient) ClaimAnyVM(resourceGroupName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ClaimAnyVMPreparer(resourceGroupName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ClaimAnyVM", nil, "Failure preparing request") + return + } + + resp, err := client.ClaimAnyVMSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ClaimAnyVM", resp, "Failure sending request") + return + } + + result, err = client.ClaimAnyVMResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ClaimAnyVM", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ClaimAnyVMPreparer prepares the ClaimAnyVM request. +func (client LabsClient) ClaimAnyVMPreparer(resourceGroupName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/claimAnyVm", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ClaimAnyVMSender sends the ClaimAnyVM request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) ClaimAnyVMSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ClaimAnyVMResponder handles the response to the ClaimAnyVM request. The method always +// closes the http.Response Body. +func (client LabsClient) ClaimAnyVMResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateEnvironment create virtual machines in a lab. This operation can take +// a while to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. labVirtualMachineCreationParameter is properties for creating a virtual +// machine. +func (client LabsClient) CreateEnvironment(resourceGroupName string, name string, labVirtualMachineCreationParameter LabVirtualMachineCreationParameter, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: labVirtualMachineCreationParameter, + Constraints: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "devtestlabs.LabsClient", "CreateEnvironment") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateEnvironmentPreparer(resourceGroupName, name, labVirtualMachineCreationParameter, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "CreateEnvironment", nil, "Failure preparing request") + return + } + + resp, err := client.CreateEnvironmentSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "CreateEnvironment", resp, "Failure sending request") + return + } + + result, err = client.CreateEnvironmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "CreateEnvironment", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateEnvironmentPreparer prepares the CreateEnvironment request. +func (client LabsClient) CreateEnvironmentPreparer(resourceGroupName string, name string, labVirtualMachineCreationParameter LabVirtualMachineCreationParameter, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment", pathParameters), + autorest.WithJSON(labVirtualMachineCreationParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateEnvironmentSender sends the CreateEnvironment request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) CreateEnvironmentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateEnvironmentResponder handles the response to the CreateEnvironment request. The method always +// closes the http.Response Body. +func (client LabsClient) CreateEnvironmentResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate create or replace an existing lab. This operation can take a +// while to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. lab is a lab. +func (client LabsClient) CreateOrUpdate(resourceGroupName string, name string, lab Lab, cancel <-chan struct{}) (<-chan Lab, <-chan error) { + resultChan := make(chan Lab, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Lab + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, lab, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LabsClient) CreateOrUpdatePreparer(resourceGroupName string, name string, lab Lab, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), + autorest.WithJSON(lab), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LabsClient) CreateOrUpdateResponder(resp *http.Response) (result Lab, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete lab. This operation can take a while to complete. This method +// may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. +func (client LabsClient) Delete(resourceGroupName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client LabsClient) DeletePreparer(resourceGroupName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LabsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ExportResourceUsage exports the lab resource usage into a storage account +// This operation can take a while to complete. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. exportResourceUsageParameters is the parameters of the export +// operation. +func (client LabsClient) ExportResourceUsage(resourceGroupName string, name string, exportResourceUsageParameters ExportResourceUsageParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ExportResourceUsagePreparer(resourceGroupName, name, exportResourceUsageParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ExportResourceUsage", nil, "Failure preparing request") + return + } + + resp, err := client.ExportResourceUsageSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ExportResourceUsage", resp, "Failure sending request") + return + } + + result, err = client.ExportResourceUsageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ExportResourceUsage", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ExportResourceUsagePreparer prepares the ExportResourceUsage request. +func (client LabsClient) ExportResourceUsagePreparer(resourceGroupName string, name string, exportResourceUsageParameters ExportResourceUsageParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/exportResourceUsage", pathParameters), + autorest.WithJSON(exportResourceUsageParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ExportResourceUsageSender sends the ExportResourceUsage request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) ExportResourceUsageSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ExportResourceUsageResponder handles the response to the ExportResourceUsage request. The method always +// closes the http.Response Body. +func (client LabsClient) ExportResourceUsageResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateUploadURI generate a URI for uploading custom disk images to a Lab. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. generateUploadURIParameter is properties for generating an upload URI. +func (client LabsClient) GenerateUploadURI(resourceGroupName string, name string, generateUploadURIParameter GenerateUploadURIParameter) (result GenerateUploadURIResponse, err error) { + req, err := client.GenerateUploadURIPreparer(resourceGroupName, name, generateUploadURIParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "GenerateUploadURI", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateUploadURISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "GenerateUploadURI", resp, "Failure sending request") + return + } + + result, err = client.GenerateUploadURIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "GenerateUploadURI", resp, "Failure responding to request") + } + + return +} + +// GenerateUploadURIPreparer prepares the GenerateUploadURI request. +func (client LabsClient) GenerateUploadURIPreparer(resourceGroupName string, name string, generateUploadURIParameter GenerateUploadURIParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/generateUploadUri", pathParameters), + autorest.WithJSON(generateUploadURIParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GenerateUploadURISender sends the GenerateUploadURI request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) GenerateUploadURISender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GenerateUploadURIResponder handles the response to the GenerateUploadURI request. The method always +// closes the http.Response Body. +func (client LabsClient) GenerateUploadURIResponder(resp *http.Response) (result GenerateUploadURIResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get lab. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. expand is specify the $expand query. Example: +// 'properties($select=defaultStorageAccount)' +func (client LabsClient) Get(resourceGroupName string, name string, expand string) (result Lab, err error) { + req, err := client.GetPreparer(resourceGroupName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LabsClient) GetPreparer(resourceGroupName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LabsClient) GetResponder(resp *http.Response) (result Lab, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list labs in a resource group. +// +// resourceGroupName is the name of the resource group. expand is specify the +// $expand query. Example: 'properties($select=defaultStorageAccount)' filter +// is the filter to apply to the operation. top is the maximum number of +// resources to return from the operation. orderby is the ordering expression +// for the results, using OData notation. +func (client LabsClient) ListByResourceGroup(resourceGroupName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLab, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client LabsClient) ListByResourceGroupPreparer(resourceGroupName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client LabsClient) ListByResourceGroupResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client LabsClient) ListByResourceGroupNextResults(lastResults ResponseWithContinuationLab) (result ResponseWithContinuationLab, err error) { + req, err := lastResults.ResponseWithContinuationLabPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// ListBySubscription list labs in a subscription. +// +// expand is specify the $expand query. Example: +// 'properties($select=defaultStorageAccount)' filter is the filter to apply to +// the operation. top is the maximum number of resources to return from the +// operation. orderby is the ordering expression for the results, using OData +// notation. +func (client LabsClient) ListBySubscription(expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLab, err error) { + req, err := client.ListBySubscriptionPreparer(expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client LabsClient) ListBySubscriptionPreparer(expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/labs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client LabsClient) ListBySubscriptionResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionNextResults retrieves the next set of results, if any. +func (client LabsClient) ListBySubscriptionNextResults(lastResults ResponseWithContinuationLab) (result ResponseWithContinuationLab, err error) { + req, err := lastResults.ResponseWithContinuationLabPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListBySubscription", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListBySubscription", resp, "Failure sending next results request") + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListBySubscription", resp, "Failure responding to next results request") + } + + return +} + +// ListVhds list disk images available for custom image creation. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. +func (client LabsClient) ListVhds(resourceGroupName string, name string) (result ResponseWithContinuationLabVhd, err error) { + req, err := client.ListVhdsPreparer(resourceGroupName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListVhds", nil, "Failure preparing request") + return + } + + resp, err := client.ListVhdsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListVhds", resp, "Failure sending request") + return + } + + result, err = client.ListVhdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListVhds", resp, "Failure responding to request") + } + + return +} + +// ListVhdsPreparer prepares the ListVhds request. +func (client LabsClient) ListVhdsPreparer(resourceGroupName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/listVhds", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListVhdsSender sends the ListVhds request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) ListVhdsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListVhdsResponder handles the response to the ListVhds request. The method always +// closes the http.Response Body. +func (client LabsClient) ListVhdsResponder(resp *http.Response) (result ResponseWithContinuationLabVhd, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListVhdsNextResults retrieves the next set of results, if any. +func (client LabsClient) ListVhdsNextResults(lastResults ResponseWithContinuationLabVhd) (result ResponseWithContinuationLabVhd, err error) { + req, err := lastResults.ResponseWithContinuationLabVhdPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListVhds", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListVhdsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListVhds", resp, "Failure sending next results request") + } + + result, err = client.ListVhdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "ListVhds", resp, "Failure responding to next results request") + } + + return +} + +// Update modify properties of labs. +// +// resourceGroupName is the name of the resource group. name is the name of the +// lab. lab is a lab. +func (client LabsClient) Update(resourceGroupName string, name string, lab LabFragment) (result Lab, err error) { + req, err := client.UpdatePreparer(resourceGroupName, name, lab) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.LabsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LabsClient) UpdatePreparer(resourceGroupName string, name string, lab LabFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters), + autorest.WithJSON(lab), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LabsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LabsClient) UpdateResponder(resp *http.Response) (result Lab, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/models.go b/arm/devtestlabs/models.go index 5b5c87d02d2f..5525e7f014e2 100644 --- a/arm/devtestlabs/models.go +++ b/arm/devtestlabs/models.go @@ -14,7 +14,7 @@ package devtestlabs // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,6 +25,28 @@ import ( "net/http" ) +// CostThresholdStatus enumerates the values for cost threshold status. +type CostThresholdStatus string + +const ( + // Disabled specifies the disabled state for cost threshold status. + Disabled CostThresholdStatus = "Disabled" + // Enabled specifies the enabled state for cost threshold status. + Enabled CostThresholdStatus = "Enabled" +) + +// CostType enumerates the values for cost type. +type CostType string + +const ( + // Projected specifies the projected state for cost type. + Projected CostType = "Projected" + // Reported specifies the reported state for cost type. + Reported CostType = "Reported" + // Unavailable specifies the unavailable state for cost type. + Unavailable CostType = "Unavailable" +) + // CustomImageOsType enumerates the values for custom image os type. type CustomImageOsType string @@ -41,32 +63,40 @@ const ( type EnableStatus string const ( - // Disabled specifies the disabled state for enable status. - Disabled EnableStatus = "Disabled" - // Enabled specifies the enabled state for enable status. - Enabled EnableStatus = "Enabled" + // EnableStatusDisabled specifies the enable status disabled state for + // enable status. + EnableStatusDisabled EnableStatus = "Disabled" + // EnableStatusEnabled specifies the enable status enabled state for enable + // status. + EnableStatusEnabled EnableStatus = "Enabled" ) -// LabCostType enumerates the values for lab cost type. -type LabCostType string +// FileUploadOptions enumerates the values for file upload options. +type FileUploadOptions string const ( - // Projected specifies the projected state for lab cost type. - Projected LabCostType = "Projected" - // Reported specifies the reported state for lab cost type. - Reported LabCostType = "Reported" - // Unavailable specifies the unavailable state for lab cost type. - Unavailable LabCostType = "Unavailable" + // FileUploadOptionsNone specifies the file upload options none state for + // file upload options. + FileUploadOptionsNone FileUploadOptions = "None" + // FileUploadOptionsUploadFilesAndGenerateSasTokens specifies the file + // upload options upload files and generate sas tokens state for file + // upload options. + FileUploadOptionsUploadFilesAndGenerateSasTokens FileUploadOptions = "UploadFilesAndGenerateSasTokens" ) -// LabStorageType enumerates the values for lab storage type. -type LabStorageType string +// HostCachingOptions enumerates the values for host caching options. +type HostCachingOptions string const ( - // Premium specifies the premium state for lab storage type. - Premium LabStorageType = "Premium" - // Standard specifies the standard state for lab storage type. - Standard LabStorageType = "Standard" + // HostCachingOptionsNone specifies the host caching options none state for + // host caching options. + HostCachingOptionsNone HostCachingOptions = "None" + // HostCachingOptionsReadOnly specifies the host caching options read only + // state for host caching options. + HostCachingOptionsReadOnly HostCachingOptions = "ReadOnly" + // HostCachingOptionsReadWrite specifies the host caching options read + // write state for host caching options. + HostCachingOptionsReadWrite HostCachingOptions = "ReadWrite" ) // LinuxOsState enumerates the values for linux os state. @@ -76,23 +106,47 @@ const ( // DeprovisionApplied specifies the deprovision applied state for linux os // state. DeprovisionApplied LinuxOsState = "DeprovisionApplied" - // DeprovisionRequested specifies the deprovision requested state for - // linux os state. + // DeprovisionRequested specifies the deprovision requested state for linux + // os state. DeprovisionRequested LinuxOsState = "DeprovisionRequested" // NonDeprovisioned specifies the non deprovisioned state for linux os // state. NonDeprovisioned LinuxOsState = "NonDeprovisioned" ) +// NotificationChannelEventType enumerates the values for notification channel +// event type. +type NotificationChannelEventType string + +const ( + // AutoShutdown specifies the auto shutdown state for notification channel + // event type. + AutoShutdown NotificationChannelEventType = "AutoShutdown" + // Cost specifies the cost state for notification channel event type. + Cost NotificationChannelEventType = "Cost" +) + +// NotificationStatus enumerates the values for notification status. +type NotificationStatus string + +const ( + // NotificationStatusDisabled specifies the notification status disabled + // state for notification status. + NotificationStatusDisabled NotificationStatus = "Disabled" + // NotificationStatusEnabled specifies the notification status enabled + // state for notification status. + NotificationStatusEnabled NotificationStatus = "Enabled" +) + // PolicyEvaluatorType enumerates the values for policy evaluator type. type PolicyEvaluatorType string const ( - // AllowedValuesPolicy specifies the allowed values policy state for - // policy evaluator type. - AllowedValuesPolicy PolicyEvaluatorType = "AllowedValuesPolicy" - // MaxValuePolicy specifies the max value policy state for policy + // AllowedValuesPolicy specifies the allowed values policy state for policy // evaluator type. + AllowedValuesPolicy PolicyEvaluatorType = "AllowedValuesPolicy" + // MaxValuePolicy specifies the max value policy state for policy evaluator + // type. MaxValuePolicy PolicyEvaluatorType = "MaxValuePolicy" ) @@ -103,17 +157,26 @@ const ( // PolicyFactNameGalleryImage specifies the policy fact name gallery image // state for policy fact name. PolicyFactNameGalleryImage PolicyFactName = "GalleryImage" + // PolicyFactNameLabPremiumVMCount specifies the policy fact name lab + // premium vm count state for policy fact name. + PolicyFactNameLabPremiumVMCount PolicyFactName = "LabPremiumVmCount" + // PolicyFactNameLabTargetCost specifies the policy fact name lab target + // cost state for policy fact name. + PolicyFactNameLabTargetCost PolicyFactName = "LabTargetCost" // PolicyFactNameLabVMCount specifies the policy fact name lab vm count // state for policy fact name. PolicyFactNameLabVMCount PolicyFactName = "LabVmCount" - // PolicyFactNameLabVMSize specifies the policy fact name lab vm size - // state for policy fact name. + // PolicyFactNameLabVMSize specifies the policy fact name lab vm size state + // for policy fact name. PolicyFactNameLabVMSize PolicyFactName = "LabVmSize" + // PolicyFactNameUserOwnedLabPremiumVMCount specifies the policy fact name + // user owned lab premium vm count state for policy fact name. + PolicyFactNameUserOwnedLabPremiumVMCount PolicyFactName = "UserOwnedLabPremiumVmCount" // PolicyFactNameUserOwnedLabVMCount specifies the policy fact name user // owned lab vm count state for policy fact name. PolicyFactNameUserOwnedLabVMCount PolicyFactName = "UserOwnedLabVmCount" - // PolicyFactNameUserOwnedLabVMCountInSubnet specifies the policy fact - // name user owned lab vm count in subnet state for policy fact name. + // PolicyFactNameUserOwnedLabVMCountInSubnet specifies the policy fact name + // user owned lab vm count in subnet state for policy fact name. PolicyFactNameUserOwnedLabVMCountInSubnet PolicyFactName = "UserOwnedLabVmCountInSubnet" ) @@ -124,11 +187,34 @@ const ( // PolicyStatusDisabled specifies the policy status disabled state for // policy status. PolicyStatusDisabled PolicyStatus = "Disabled" - // PolicyStatusEnabled specifies the policy status enabled state for - // policy status. + // PolicyStatusEnabled specifies the policy status enabled state for policy + // status. PolicyStatusEnabled PolicyStatus = "Enabled" ) +// PremiumDataDisk enumerates the values for premium data disk. +type PremiumDataDisk string + +const ( + // PremiumDataDiskDisabled specifies the premium data disk disabled state + // for premium data disk. + PremiumDataDiskDisabled PremiumDataDisk = "Disabled" + // PremiumDataDiskEnabled specifies the premium data disk enabled state for + // premium data disk. + PremiumDataDiskEnabled PremiumDataDisk = "Enabled" +) + +// ReportingCycleType enumerates the values for reporting cycle type. +type ReportingCycleType string + +const ( + // CalendarMonth specifies the calendar month state for reporting cycle + // type. + CalendarMonth ReportingCycleType = "CalendarMonth" + // Custom specifies the custom state for reporting cycle type. + Custom ReportingCycleType = "Custom" +) + // SourceControlType enumerates the values for source control type. type SourceControlType string @@ -139,27 +225,36 @@ const ( VsoGit SourceControlType = "VsoGit" ) -// SubscriptionNotificationState enumerates the values for subscription -// notification state. -type SubscriptionNotificationState string +// StorageType enumerates the values for storage type. +type StorageType string const ( - // Deleted specifies the deleted state for subscription notification state. - Deleted SubscriptionNotificationState = "Deleted" - // NotDefined specifies the not defined state for subscription - // notification state. - NotDefined SubscriptionNotificationState = "NotDefined" - // Registered specifies the registered state for subscription notification - // state. - Registered SubscriptionNotificationState = "Registered" - // Suspended specifies the suspended state for subscription notification - // state. - Suspended SubscriptionNotificationState = "Suspended" - // Unregistered specifies the unregistered state for subscription - // notification state. - Unregistered SubscriptionNotificationState = "Unregistered" - // Warned specifies the warned state for subscription notification state. - Warned SubscriptionNotificationState = "Warned" + // Premium specifies the premium state for storage type. + Premium StorageType = "Premium" + // Standard specifies the standard state for storage type. + Standard StorageType = "Standard" +) + +// TargetCostStatus enumerates the values for target cost status. +type TargetCostStatus string + +const ( + // TargetCostStatusDisabled specifies the target cost status disabled state + // for target cost status. + TargetCostStatusDisabled TargetCostStatus = "Disabled" + // TargetCostStatusEnabled specifies the target cost status enabled state + // for target cost status. + TargetCostStatusEnabled TargetCostStatus = "Enabled" +) + +// TransportProtocol enumerates the values for transport protocol. +type TransportProtocol string + +const ( + // TCP specifies the tcp state for transport protocol. + TCP TransportProtocol = "Tcp" + // UDP specifies the udp state for transport protocol. + UDP TransportProtocol = "Udp" ) // UsagePermissionType enumerates the values for usage permission type. @@ -174,6 +269,19 @@ const ( Deny UsagePermissionType = "Deny" ) +// VirtualMachineCreationSource enumerates the values for virtual machine +// creation source. +type VirtualMachineCreationSource string + +const ( + // FromCustomImage specifies the from custom image state for virtual + // machine creation source. + FromCustomImage VirtualMachineCreationSource = "FromCustomImage" + // FromGalleryImage specifies the from gallery image state for virtual + // machine creation source. + FromGalleryImage VirtualMachineCreationSource = "FromGalleryImage" +) + // WindowsOsState enumerates the values for windows os state. type WindowsOsState string @@ -187,12 +295,60 @@ const ( SysprepRequested WindowsOsState = "SysprepRequested" ) +// ApplicableSchedule is schedules applicable to a virtual machine. The +// schedules may have been defined on a VM or on lab level. +type ApplicableSchedule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ApplicableScheduleProperties `json:"properties,omitempty"` +} + +// ApplicableScheduleFragment is schedules applicable to a virtual machine. The +// schedules may have been defined on a VM or on lab level. +type ApplicableScheduleFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ApplicableSchedulePropertiesFragment `json:"properties,omitempty"` +} + +// ApplicableScheduleProperties is properties of a schedules applicable to a +// virtual machine. +type ApplicableScheduleProperties struct { + LabVmsShutdown *Schedule `json:"labVmsShutdown,omitempty"` + LabVmsStartup *Schedule `json:"labVmsStartup,omitempty"` +} + +// ApplicableSchedulePropertiesFragment is properties of a schedules applicable +// to a virtual machine. +type ApplicableSchedulePropertiesFragment struct { + LabVmsShutdown *ScheduleFragment `json:"labVmsShutdown,omitempty"` + LabVmsStartup *ScheduleFragment `json:"labVmsStartup,omitempty"` +} + // ApplyArtifactsRequest is request body for applying artifacts to a virtual // machine. type ApplyArtifactsRequest struct { Artifacts *[]ArtifactInstallProperties `json:"artifacts,omitempty"` } +// ArmTemplate is an Azure Resource Manager template. +type ArmTemplate struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ArmTemplateProperties `json:"properties,omitempty"` +} + // ArmTemplateInfo is information about a generated ARM template. type ArmTemplateInfo struct { autorest.Response `json:"-"` @@ -200,15 +356,33 @@ type ArmTemplateInfo struct { Parameters *map[string]interface{} `json:"parameters,omitempty"` } +// ArmTemplateParameterProperties is properties of an Azure Resource Manager +// template parameter. +type ArmTemplateParameterProperties struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ArmTemplateProperties is properties of an Azure Resource Manager template. +type ArmTemplateProperties struct { + DisplayName *string `json:"displayName,omitempty"` + Description *string `json:"description,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Icon *string `json:"icon,omitempty"` + Contents *map[string]interface{} `json:"contents,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + ParametersValueFilesInfo *[]ParametersValueFileInfo `json:"parametersValueFilesInfo,omitempty"` +} + // Artifact is an artifact. type Artifact struct { autorest.Response `json:"-"` - *ArtifactProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *ArtifactProperties `json:"properties,omitempty"` } // ArtifactDeploymentStatusProperties is properties of an artifact deployment. @@ -218,10 +392,32 @@ type ArtifactDeploymentStatusProperties struct { TotalArtifacts *int32 `json:"totalArtifacts,omitempty"` } +// ArtifactDeploymentStatusPropertiesFragment is properties of an artifact +// deployment. +type ArtifactDeploymentStatusPropertiesFragment struct { + DeploymentStatus *string `json:"deploymentStatus,omitempty"` + ArtifactsApplied *int32 `json:"artifactsApplied,omitempty"` + TotalArtifacts *int32 `json:"totalArtifacts,omitempty"` +} + // ArtifactInstallProperties is properties of an artifact. type ArtifactInstallProperties struct { - ArtifactID *string `json:"artifactId,omitempty"` - Parameters *[]ArtifactParameterProperties `json:"parameters,omitempty"` + ArtifactID *string `json:"artifactId,omitempty"` + Parameters *[]ArtifactParameterProperties `json:"parameters,omitempty"` + Status *string `json:"status,omitempty"` + DeploymentStatusMessage *string `json:"deploymentStatusMessage,omitempty"` + VMExtensionStatusMessage *string `json:"vmExtensionStatusMessage,omitempty"` + InstallTime *date.Time `json:"installTime,omitempty"` +} + +// ArtifactInstallPropertiesFragment is properties of an artifact. +type ArtifactInstallPropertiesFragment struct { + ArtifactID *string `json:"artifactId,omitempty"` + Parameters *[]ArtifactParameterPropertiesFragment `json:"parameters,omitempty"` + Status *string `json:"status,omitempty"` + DeploymentStatusMessage *string `json:"deploymentStatusMessage,omitempty"` + VMExtensionStatusMessage *string `json:"vmExtensionStatusMessage,omitempty"` + InstallTime *date.Time `json:"installTime,omitempty"` } // ArtifactParameterProperties is properties of an artifact parameter. @@ -230,46 +426,99 @@ type ArtifactParameterProperties struct { Value *string `json:"value,omitempty"` } +// ArtifactParameterPropertiesFragment is properties of an artifact parameter. +type ArtifactParameterPropertiesFragment struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + // ArtifactProperties is properties of an artifact. type ArtifactProperties struct { Title *string `json:"title,omitempty"` Description *string `json:"description,omitempty"` + Publisher *string `json:"publisher,omitempty"` FilePath *string `json:"filePath,omitempty"` Icon *string `json:"icon,omitempty"` TargetOsType *string `json:"targetOsType,omitempty"` Parameters *map[string]interface{} `json:"parameters,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` } // ArtifactSource is properties of an artifact source. type ArtifactSource struct { autorest.Response `json:"-"` - *ArtifactSourceProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *ArtifactSourceProperties `json:"properties,omitempty"` +} + +// ArtifactSourceFragment is properties of an artifact source. +type ArtifactSourceFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ArtifactSourcePropertiesFragment `json:"properties,omitempty"` } // ArtifactSourceProperties is properties of an artifact source. type ArtifactSourceProperties struct { - DisplayName *string `json:"displayName,omitempty"` - URI *string `json:"uri,omitempty"` - SourceType SourceControlType `json:"sourceType,omitempty"` - FolderPath *string `json:"folderPath,omitempty"` - BranchRef *string `json:"branchRef,omitempty"` - SecurityToken *string `json:"securityToken,omitempty"` - Status EnableStatus `json:"status,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` - UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` -} - -// CloudError is + DisplayName *string `json:"displayName,omitempty"` + URI *string `json:"uri,omitempty"` + SourceType SourceControlType `json:"sourceType,omitempty"` + FolderPath *string `json:"folderPath,omitempty"` + ArmTemplateFolderPath *string `json:"armTemplateFolderPath,omitempty"` + BranchRef *string `json:"branchRef,omitempty"` + SecurityToken *string `json:"securityToken,omitempty"` + Status EnableStatus `json:"status,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// ArtifactSourcePropertiesFragment is properties of an artifact source. +type ArtifactSourcePropertiesFragment struct { + DisplayName *string `json:"displayName,omitempty"` + URI *string `json:"uri,omitempty"` + SourceType SourceControlType `json:"sourceType,omitempty"` + FolderPath *string `json:"folderPath,omitempty"` + ArmTemplateFolderPath *string `json:"armTemplateFolderPath,omitempty"` + BranchRef *string `json:"branchRef,omitempty"` + SecurityToken *string `json:"securityToken,omitempty"` + Status EnableStatus `json:"status,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// AttachDiskProperties is properties of the disk to attach. +type AttachDiskProperties struct { + LeasedByLabVMID *string `json:"leasedByLabVmId,omitempty"` +} + +// AttachNewDataDiskOptions is properties to attach new disk to the Virtual +// Machine. +type AttachNewDataDiskOptions struct { + DiskSizeGiB *int32 `json:"diskSizeGiB,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskType StorageType `json:"diskType,omitempty"` +} + +// BulkCreationParameters is parameters for creating multiple virtual machines +// as a single action. +type BulkCreationParameters struct { + InstanceCount *int32 `json:"instanceCount,omitempty"` +} + +// CloudError is error from a REST request. type CloudError struct { Error *CloudErrorBody `json:"error,omitempty"` } -// CloudErrorBody is +// CloudErrorBody is body of an error from a REST request. type CloudErrorBody struct { Code *string `json:"code,omitempty"` Message *string `json:"message,omitempty"` @@ -277,40 +526,79 @@ type CloudErrorBody struct { Details *[]CloudErrorBody `json:"details,omitempty"` } -// Cost is a cost item. -type Cost struct { - autorest.Response `json:"-"` - *CostProperties `json:"properties,omitempty"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` +// ComputeDataDisk is a data disks attached to a virtual machine. +type ComputeDataDisk struct { + Name *string `json:"name,omitempty"` + DiskURI *string `json:"diskUri,omitempty"` + ManagedDiskID *string `json:"managedDiskId,omitempty"` + DiskSizeGiB *int32 `json:"diskSizeGiB,omitempty"` } -// CostPerDayProperties is the properties of a lab cost item. -type CostPerDayProperties struct { - Date *date.Time `json:"date,omitempty"` - Cost *float64 `json:"cost,omitempty"` - CostType LabCostType `json:"costType,omitempty"` +// ComputeDataDiskFragment is a data disks attached to a virtual machine. +type ComputeDataDiskFragment struct { + Name *string `json:"name,omitempty"` + DiskURI *string `json:"diskUri,omitempty"` + ManagedDiskID *string `json:"managedDiskId,omitempty"` + DiskSizeGiB *int32 `json:"diskSizeGiB,omitempty"` } -// CostProperties is properties of a cost item. -type CostProperties struct { - CurrencyCode *string `json:"currencyCode,omitempty"` - Costs *[]CostPerDayProperties `json:"costs,omitempty"` - ResourceCosts *[]ResourceCostProperties `json:"resourceCosts,omitempty"` +// ComputeVMInstanceViewStatus is status information about a virtual machine. +type ComputeVMInstanceViewStatus struct { + Code *string `json:"code,omitempty"` + DisplayStatus *string `json:"displayStatus,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ComputeVMInstanceViewStatusFragment is status information about a virtual +// machine. +type ComputeVMInstanceViewStatusFragment struct { + Code *string `json:"code,omitempty"` + DisplayStatus *string `json:"displayStatus,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ComputeVMProperties is properties of a virtual machine returned by the +// Microsoft.Compute API. +type ComputeVMProperties struct { + Statuses *[]ComputeVMInstanceViewStatus `json:"statuses,omitempty"` + OsType *string `json:"osType,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + NetworkInterfaceID *string `json:"networkInterfaceId,omitempty"` + OsDiskID *string `json:"osDiskId,omitempty"` + DataDiskIds *[]string `json:"dataDiskIds,omitempty"` + DataDisks *[]ComputeDataDisk `json:"dataDisks,omitempty"` +} + +// ComputeVMPropertiesFragment is properties of a virtual machine returned by +// the Microsoft.Compute API. +type ComputeVMPropertiesFragment struct { + Statuses *[]ComputeVMInstanceViewStatusFragment `json:"statuses,omitempty"` + OsType *string `json:"osType,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + NetworkInterfaceID *string `json:"networkInterfaceId,omitempty"` + OsDiskID *string `json:"osDiskId,omitempty"` + DataDiskIds *[]string `json:"dataDiskIds,omitempty"` + DataDisks *[]ComputeDataDiskFragment `json:"dataDisks,omitempty"` +} + +// CostThresholdProperties is properties of a cost threshold item. +type CostThresholdProperties struct { + ThresholdID *string `json:"thresholdId,omitempty"` + PercentageThreshold *PercentageCostThresholdProperties `json:"percentageThreshold,omitempty"` + DisplayOnChart CostThresholdStatus `json:"displayOnChart,omitempty"` + SendNotificationWhenExceeded CostThresholdStatus `json:"sendNotificationWhenExceeded,omitempty"` + NotificationSent *string `json:"NotificationSent,omitempty"` } // CustomImage is a custom image. type CustomImage struct { autorest.Response `json:"-"` - *CustomImageProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *CustomImageProperties `json:"properties,omitempty"` } // CustomImageProperties is properties of a custom image. @@ -320,31 +608,109 @@ type CustomImageProperties struct { Description *string `json:"description,omitempty"` Author *string `json:"author,omitempty"` CreationDate *date.Time `json:"creationDate,omitempty"` + ManagedImageID *string `json:"managedImageId,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` } -// CustomImagePropertiesCustom is properties for creating a custom image from -// a VHD. +// CustomImagePropertiesCustom is properties for creating a custom image from a +// VHD. type CustomImagePropertiesCustom struct { ImageName *string `json:"imageName,omitempty"` SysPrep *bool `json:"sysPrep,omitempty"` OsType CustomImageOsType `json:"osType,omitempty"` } -// CustomImagePropertiesFromVM is properties for creating a custom image from -// a virtual machine. +// CustomImagePropertiesFromVM is properties for creating a custom image from a +// virtual machine. type CustomImagePropertiesFromVM struct { SourceVMID *string `json:"sourceVmId,omitempty"` WindowsOsInfo *WindowsOsInfo `json:"windowsOsInfo,omitempty"` LinuxOsInfo *LinuxOsInfo `json:"linuxOsInfo,omitempty"` } +// DataDiskProperties is request body for adding a new or existing data disk to +// a virtual machine. +type DataDiskProperties struct { + AttachNewDataDiskOptions *AttachNewDataDiskOptions `json:"attachNewDataDiskOptions,omitempty"` + ExistingLabDiskID *string `json:"existingLabDiskId,omitempty"` + HostCaching HostCachingOptions `json:"hostCaching,omitempty"` +} + // DayDetails is properties of a daily schedule. type DayDetails struct { Time *string `json:"time,omitempty"` } +// DayDetailsFragment is properties of a daily schedule. +type DayDetailsFragment struct { + Time *string `json:"time,omitempty"` +} + +// DetachDataDiskProperties is request body for detaching data disk from a +// virtual machine. +type DetachDataDiskProperties struct { + ExistingLabDiskID *string `json:"existingLabDiskId,omitempty"` +} + +// DetachDiskProperties is properties of the disk to detach. +type DetachDiskProperties struct { + LeasedByLabVMID *string `json:"leasedByLabVmId,omitempty"` +} + +// Disk is a Disk. +type Disk struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *DiskProperties `json:"properties,omitempty"` +} + +// DiskProperties is properties of a disk. +type DiskProperties struct { + DiskType StorageType `json:"diskType,omitempty"` + DiskSizeGiB *int32 `json:"diskSizeGiB,omitempty"` + LeasedByLabVMID *string `json:"leasedByLabVmId,omitempty"` + DiskBlobName *string `json:"diskBlobName,omitempty"` + DiskURI *string `json:"diskUri,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + HostCaching *string `json:"hostCaching,omitempty"` + ManagedDiskID *string `json:"managedDiskId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// DtlEnvironment is an environment, which is essentially an ARM template +// deployment. +type DtlEnvironment struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *EnvironmentProperties `json:"properties,omitempty"` +} + +// EnvironmentDeploymentProperties is properties of an environment deployment. +type EnvironmentDeploymentProperties struct { + ArmTemplateID *string `json:"armTemplateId,omitempty"` + Parameters *[]ArmTemplateParameterProperties `json:"parameters,omitempty"` +} + +// EnvironmentProperties is properties of an environment. +type EnvironmentProperties struct { + DeploymentProperties *EnvironmentDeploymentProperties `json:"deploymentProperties,omitempty"` + ArmTemplateDisplayName *string `json:"armTemplateDisplayName,omitempty"` + ResourceGroupID *string `json:"resourceGroupId,omitempty"` + CreatedByUser *string `json:"createdByUser,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + // EvaluatePoliciesProperties is properties for evaluating a policy set. type EvaluatePoliciesProperties struct { FactName *string `json:"factName,omitempty"` @@ -363,43 +729,74 @@ type EvaluatePoliciesResponse struct { Results *[]PolicySetResult `json:"results,omitempty"` } -// Formula is a formula. +// Event is an event to be notified for. +type Event struct { + EventName NotificationChannelEventType `json:"eventName,omitempty"` +} + +// EventFragment is an event to be notified for. +type EventFragment struct { + EventName NotificationChannelEventType `json:"eventName,omitempty"` +} + +// ExportResourceUsageParameters is the parameters of the export operation. +type ExportResourceUsageParameters struct { + BlobStorageAbsoluteSasURI *string `json:"blobStorageAbsoluteSasUri,omitempty"` + UsageStartDate *date.Time `json:"usageStartDate,omitempty"` +} + +// ExternalSubnet is subnet information as returned by the Microsoft.Network +// API. +type ExternalSubnet struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +// ExternalSubnetFragment is subnet information as returned by the +// Microsoft.Network API. +type ExternalSubnetFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +// Formula is a formula for creating a VM, specifying an image base and other +// parameters type Formula struct { autorest.Response `json:"-"` - *FormulaProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *FormulaProperties `json:"properties,omitempty"` } // FormulaProperties is properties of a formula. type FormulaProperties struct { - Description *string `json:"description,omitempty"` - Author *string `json:"author,omitempty"` - OsType *string `json:"osType,omitempty"` - CreationDate *date.Time `json:"creationDate,omitempty"` - FormulaContent *LabVirtualMachine `json:"formulaContent,omitempty"` - VM *FormulaPropertiesFromVM `json:"vm,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` - UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` -} - -// FormulaPropertiesFromVM is information about a VM from which a formula is -// to be created. + Description *string `json:"description,omitempty"` + Author *string `json:"author,omitempty"` + OsType *string `json:"osType,omitempty"` + CreationDate *date.Time `json:"creationDate,omitempty"` + FormulaContent *LabVirtualMachineCreationParameter `json:"formulaContent,omitempty"` + VM *FormulaPropertiesFromVM `json:"vm,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// FormulaPropertiesFromVM is information about a VM from which a formula is to +// be created. type FormulaPropertiesFromVM struct { LabVMID *string `json:"labVmId,omitempty"` } // GalleryImage is a gallery image. type GalleryImage struct { - *GalleryImageProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *GalleryImageProperties `json:"properties,omitempty"` } // GalleryImageProperties is properties of a gallery image. @@ -422,12 +819,23 @@ type GalleryImageReference struct { Version *string `json:"version,omitempty"` } +// GalleryImageReferenceFragment is the reference information for an Azure +// Marketplace image. +type GalleryImageReferenceFragment struct { + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Sku *string `json:"sku,omitempty"` + OsType *string `json:"osType,omitempty"` + Version *string `json:"version,omitempty"` +} + // GenerateArmTemplateRequest is parameters for generating an ARM template for // deploying artifacts. type GenerateArmTemplateRequest struct { - VirtualMachineName *string `json:"virtualMachineName,omitempty"` - Parameters *[]ParameterInfo `json:"parameters,omitempty"` - Location *string `json:"location,omitempty"` + VirtualMachineName *string `json:"virtualMachineName,omitempty"` + Parameters *[]ParameterInfo `json:"parameters,omitempty"` + Location *string `json:"location,omitempty"` + FileUploadOptions FileUploadOptions `json:"fileUploadOptions,omitempty"` } // GenerateUploadURIParameter is properties for generating an upload URI. @@ -446,26 +854,126 @@ type HourDetails struct { Minute *int32 `json:"minute,omitempty"` } +// HourDetailsFragment is properties of an hourly schedule. +type HourDetailsFragment struct { + Minute *int32 `json:"minute,omitempty"` +} + +// IdentityProperties is identityProperties +type IdentityProperties struct { + Type *string `json:"type,omitempty"` + PrincipalID *string `json:"principalId,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + ClientSecretURL *string `json:"clientSecretUrl,omitempty"` +} + +// InboundNatRule is a rule for NAT - exposing a VM's port (backendPort) on the +// public IP address using a load balancer. +type InboundNatRule struct { + TransportProtocol TransportProtocol `json:"transportProtocol,omitempty"` + FrontendPort *int32 `json:"frontendPort,omitempty"` + BackendPort *int32 `json:"backendPort,omitempty"` +} + +// InboundNatRuleFragment is a rule for NAT - exposing a VM's port +// (backendPort) on the public IP address using a load balancer. +type InboundNatRuleFragment struct { + TransportProtocol TransportProtocol `json:"transportProtocol,omitempty"` + FrontendPort *int32 `json:"frontendPort,omitempty"` + BackendPort *int32 `json:"backendPort,omitempty"` +} + // Lab is a lab. type Lab struct { autorest.Response `json:"-"` - *LabProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *LabProperties `json:"properties,omitempty"` +} + +// LabCost is a cost item. +type LabCost struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *LabCostProperties `json:"properties,omitempty"` +} + +// LabCostDetailsProperties is the properties of a lab cost item. +type LabCostDetailsProperties struct { + Date *date.Time `json:"date,omitempty"` + Cost *float64 `json:"cost,omitempty"` + CostType CostType `json:"costType,omitempty"` +} + +// LabCostProperties is properties of a cost item. +type LabCostProperties struct { + TargetCost *TargetCostProperties `json:"targetCost,omitempty"` + LabCostSummary *LabCostSummaryProperties `json:"labCostSummary,omitempty"` + LabCostDetails *[]LabCostDetailsProperties `json:"labCostDetails,omitempty"` + ResourceCosts *[]LabResourceCostProperties `json:"resourceCosts,omitempty"` + CurrencyCode *string `json:"currencyCode,omitempty"` + StartDateTime *date.Time `json:"startDateTime,omitempty"` + EndDateTime *date.Time `json:"endDateTime,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// LabCostSummaryProperties is the properties of the cost summary. +type LabCostSummaryProperties struct { + EstimatedLabCost *float64 `json:"estimatedLabCost,omitempty"` +} + +// LabFragment is a lab. +type LabFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *LabPropertiesFragment `json:"properties,omitempty"` } // LabProperties is properties of a lab. type LabProperties struct { - DefaultStorageAccount *string `json:"defaultStorageAccount,omitempty"` - ArtifactsStorageAccount *string `json:"artifactsStorageAccount,omitempty"` - VaultName *string `json:"vaultName,omitempty"` - LabStorageType LabStorageType `json:"labStorageType,omitempty"` - CreatedDate *date.Time `json:"createdDate,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` - UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` + DefaultStorageAccount *string `json:"defaultStorageAccount,omitempty"` + DefaultPremiumStorageAccount *string `json:"defaultPremiumStorageAccount,omitempty"` + ArtifactsStorageAccount *string `json:"artifactsStorageAccount,omitempty"` + PremiumDataDiskStorageAccount *string `json:"premiumDataDiskStorageAccount,omitempty"` + VaultName *string `json:"vaultName,omitempty"` + LabStorageType StorageType `json:"labStorageType,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + PremiumDataDisks PremiumDataDisk `json:"premiumDataDisks,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// LabPropertiesFragment is properties of a lab. +type LabPropertiesFragment struct { + LabStorageType StorageType `json:"labStorageType,omitempty"` + PremiumDataDisks PremiumDataDisk `json:"premiumDataDisks,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// LabResourceCostProperties is the properties of a resource cost item. +type LabResourceCostProperties struct { + Resourcename *string `json:"resourcename,omitempty"` + ResourceUID *string `json:"resourceUId,omitempty"` + ResourceCost *float64 `json:"resourceCost,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + ResourceOwner *string `json:"resourceOwner,omitempty"` + ResourcePricingTier *string `json:"resourcePricingTier,omitempty"` + ResourceStatus *string `json:"resourceStatus,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + ExternalResourceID *string `json:"externalResourceId,omitempty"` } // LabVhd is properties of a VHD in the lab. @@ -476,37 +984,136 @@ type LabVhd struct { // LabVirtualMachine is a virtual machine. type LabVirtualMachine struct { autorest.Response `json:"-"` - *LabVirtualMachineProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *LabVirtualMachineProperties `json:"properties,omitempty"` +} + +// LabVirtualMachineCreationParameter is properties for creating a virtual +// machine. +type LabVirtualMachineCreationParameter struct { + *LabVirtualMachineCreationParameterProperties `json:"properties,omitempty"` + Name *string `json:"name,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// LabVirtualMachineCreationParameterProperties is properties for virtual +// machine creation. +type LabVirtualMachineCreationParameterProperties struct { + BulkCreationParameters *BulkCreationParameters `json:"bulkCreationParameters,omitempty"` + Notes *string `json:"notes,omitempty"` + OwnerObjectID *string `json:"ownerObjectId,omitempty"` + OwnerUserPrincipalName *string `json:"ownerUserPrincipalName,omitempty"` + CreatedByUserID *string `json:"createdByUserId,omitempty"` + CreatedByUser *string `json:"createdByUser,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + CustomImageID *string `json:"customImageId,omitempty"` + OsType *string `json:"osType,omitempty"` + Size *string `json:"size,omitempty"` + UserName *string `json:"userName,omitempty"` + Password *string `json:"password,omitempty"` + SSHKey *string `json:"sshKey,omitempty"` + IsAuthenticationWithSSHKey *bool `json:"isAuthenticationWithSshKey,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + LabSubnetName *string `json:"labSubnetName,omitempty"` + LabVirtualNetworkID *string `json:"labVirtualNetworkId,omitempty"` + DisallowPublicIPAddress *bool `json:"disallowPublicIpAddress,omitempty"` + Artifacts *[]ArtifactInstallProperties `json:"artifacts,omitempty"` + ArtifactDeploymentStatus *ArtifactDeploymentStatusProperties `json:"artifactDeploymentStatus,omitempty"` + GalleryImageReference *GalleryImageReference `json:"galleryImageReference,omitempty"` + ComputeVM *ComputeVMProperties `json:"computeVm,omitempty"` + NetworkInterface *NetworkInterfaceProperties `json:"networkInterface,omitempty"` + ApplicableSchedule *ApplicableSchedule `json:"applicableSchedule,omitempty"` + ExpirationDate *date.Time `json:"expirationDate,omitempty"` + AllowClaim *bool `json:"allowClaim,omitempty"` + StorageType *string `json:"storageType,omitempty"` + VirtualMachineCreationSource VirtualMachineCreationSource `json:"virtualMachineCreationSource,omitempty"` + EnvironmentID *string `json:"environmentId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// LabVirtualMachineFragment is a virtual machine. +type LabVirtualMachineFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *LabVirtualMachinePropertiesFragment `json:"properties,omitempty"` } // LabVirtualMachineProperties is properties of a virtual machine. type LabVirtualMachineProperties struct { - Notes *string `json:"notes,omitempty"` - OwnerObjectID *string `json:"ownerObjectId,omitempty"` - CreatedByUserID *string `json:"createdByUserId,omitempty"` - CreatedByUser *string `json:"createdByUser,omitempty"` - ComputeID *string `json:"computeId,omitempty"` - CustomImageID *string `json:"customImageId,omitempty"` - OsType *string `json:"osType,omitempty"` - Size *string `json:"size,omitempty"` - UserName *string `json:"userName,omitempty"` - Password *string `json:"password,omitempty"` - SSHKey *string `json:"sshKey,omitempty"` - IsAuthenticationWithSSHKey *bool `json:"isAuthenticationWithSshKey,omitempty"` - Fqdn *string `json:"fqdn,omitempty"` - LabSubnetName *string `json:"labSubnetName,omitempty"` - LabVirtualNetworkID *string `json:"labVirtualNetworkId,omitempty"` - DisallowPublicIPAddress *bool `json:"disallowPublicIpAddress,omitempty"` - Artifacts *[]ArtifactInstallProperties `json:"artifacts,omitempty"` - ArtifactDeploymentStatus *ArtifactDeploymentStatusProperties `json:"artifactDeploymentStatus,omitempty"` - GalleryImageReference *GalleryImageReference `json:"galleryImageReference,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` - UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` + Notes *string `json:"notes,omitempty"` + OwnerObjectID *string `json:"ownerObjectId,omitempty"` + OwnerUserPrincipalName *string `json:"ownerUserPrincipalName,omitempty"` + CreatedByUserID *string `json:"createdByUserId,omitempty"` + CreatedByUser *string `json:"createdByUser,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + ComputeID *string `json:"computeId,omitempty"` + CustomImageID *string `json:"customImageId,omitempty"` + OsType *string `json:"osType,omitempty"` + Size *string `json:"size,omitempty"` + UserName *string `json:"userName,omitempty"` + Password *string `json:"password,omitempty"` + SSHKey *string `json:"sshKey,omitempty"` + IsAuthenticationWithSSHKey *bool `json:"isAuthenticationWithSshKey,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + LabSubnetName *string `json:"labSubnetName,omitempty"` + LabVirtualNetworkID *string `json:"labVirtualNetworkId,omitempty"` + DisallowPublicIPAddress *bool `json:"disallowPublicIpAddress,omitempty"` + Artifacts *[]ArtifactInstallProperties `json:"artifacts,omitempty"` + ArtifactDeploymentStatus *ArtifactDeploymentStatusProperties `json:"artifactDeploymentStatus,omitempty"` + GalleryImageReference *GalleryImageReference `json:"galleryImageReference,omitempty"` + ComputeVM *ComputeVMProperties `json:"computeVm,omitempty"` + NetworkInterface *NetworkInterfaceProperties `json:"networkInterface,omitempty"` + ApplicableSchedule *ApplicableSchedule `json:"applicableSchedule,omitempty"` + ExpirationDate *date.Time `json:"expirationDate,omitempty"` + AllowClaim *bool `json:"allowClaim,omitempty"` + StorageType *string `json:"storageType,omitempty"` + VirtualMachineCreationSource VirtualMachineCreationSource `json:"virtualMachineCreationSource,omitempty"` + EnvironmentID *string `json:"environmentId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// LabVirtualMachinePropertiesFragment is properties of a virtual machine. +type LabVirtualMachinePropertiesFragment struct { + Notes *string `json:"notes,omitempty"` + OwnerObjectID *string `json:"ownerObjectId,omitempty"` + OwnerUserPrincipalName *string `json:"ownerUserPrincipalName,omitempty"` + CreatedByUserID *string `json:"createdByUserId,omitempty"` + CreatedByUser *string `json:"createdByUser,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + CustomImageID *string `json:"customImageId,omitempty"` + OsType *string `json:"osType,omitempty"` + Size *string `json:"size,omitempty"` + UserName *string `json:"userName,omitempty"` + Password *string `json:"password,omitempty"` + SSHKey *string `json:"sshKey,omitempty"` + IsAuthenticationWithSSHKey *bool `json:"isAuthenticationWithSshKey,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + LabSubnetName *string `json:"labSubnetName,omitempty"` + LabVirtualNetworkID *string `json:"labVirtualNetworkId,omitempty"` + DisallowPublicIPAddress *bool `json:"disallowPublicIpAddress,omitempty"` + Artifacts *[]ArtifactInstallPropertiesFragment `json:"artifacts,omitempty"` + ArtifactDeploymentStatus *ArtifactDeploymentStatusPropertiesFragment `json:"artifactDeploymentStatus,omitempty"` + GalleryImageReference *GalleryImageReferenceFragment `json:"galleryImageReference,omitempty"` + ComputeVM *ComputeVMPropertiesFragment `json:"computeVm,omitempty"` + NetworkInterface *NetworkInterfacePropertiesFragment `json:"networkInterface,omitempty"` + ApplicableSchedule *ApplicableScheduleFragment `json:"applicableSchedule,omitempty"` + ExpirationDate *date.Time `json:"expirationDate,omitempty"` + AllowClaim *bool `json:"allowClaim,omitempty"` + StorageType *string `json:"storageType,omitempty"` + VirtualMachineCreationSource VirtualMachineCreationSource `json:"virtualMachineCreationSource,omitempty"` + EnvironmentID *string `json:"environmentId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` } // LinuxOsInfo is information about a Linux OS. @@ -514,25 +1121,147 @@ type LinuxOsInfo struct { LinuxOsState LinuxOsState `json:"linuxOsState,omitempty"` } -// ParameterInfo is +// NetworkInterfaceProperties is properties of a network interface. +type NetworkInterfaceProperties struct { + VirtualNetworkID *string `json:"virtualNetworkId,omitempty"` + SubnetID *string `json:"subnetId,omitempty"` + PublicIPAddressID *string `json:"publicIpAddressId,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + DNSName *string `json:"dnsName,omitempty"` + RdpAuthority *string `json:"rdpAuthority,omitempty"` + SSHAuthority *string `json:"sshAuthority,omitempty"` + SharedPublicIPAddressConfiguration *SharedPublicIPAddressConfiguration `json:"sharedPublicIpAddressConfiguration,omitempty"` +} + +// NetworkInterfacePropertiesFragment is properties of a network interface. +type NetworkInterfacePropertiesFragment struct { + VirtualNetworkID *string `json:"virtualNetworkId,omitempty"` + SubnetID *string `json:"subnetId,omitempty"` + PublicIPAddressID *string `json:"publicIpAddressId,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + DNSName *string `json:"dnsName,omitempty"` + RdpAuthority *string `json:"rdpAuthority,omitempty"` + SSHAuthority *string `json:"sshAuthority,omitempty"` + SharedPublicIPAddressConfiguration *SharedPublicIPAddressConfigurationFragment `json:"sharedPublicIpAddressConfiguration,omitempty"` +} + +// NotificationChannel is a notification. +type NotificationChannel struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *NotificationChannelProperties `json:"properties,omitempty"` +} + +// NotificationChannelFragment is a notification. +type NotificationChannelFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *NotificationChannelPropertiesFragment `json:"properties,omitempty"` +} + +// NotificationChannelProperties is properties of a schedule. +type NotificationChannelProperties struct { + WebHookURL *string `json:"webHookUrl,omitempty"` + Description *string `json:"description,omitempty"` + Events *[]Event `json:"events,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// NotificationChannelPropertiesFragment is properties of a schedule. +type NotificationChannelPropertiesFragment struct { + WebHookURL *string `json:"webHookUrl,omitempty"` + Description *string `json:"description,omitempty"` + Events *[]EventFragment `json:"events,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// NotificationSettings is notification settings for a schedule. +type NotificationSettings struct { + Status NotificationStatus `json:"status,omitempty"` + TimeInMinutes *int32 `json:"timeInMinutes,omitempty"` + WebhookURL *string `json:"webhookUrl,omitempty"` +} + +// NotificationSettingsFragment is notification settings for a schedule. +type NotificationSettingsFragment struct { + Status NotificationStatus `json:"status,omitempty"` + TimeInMinutes *int32 `json:"timeInMinutes,omitempty"` + WebhookURL *string `json:"webhookUrl,omitempty"` +} + +// NotifyParameters is properties for generating a Notification. +type NotifyParameters struct { + EventName NotificationChannelEventType `json:"eventName,omitempty"` + JSONPayload *string `json:"jsonPayload,omitempty"` +} + +// ParameterInfo is information about an artifact's parameter. type ParameterInfo struct { Name *string `json:"name,omitempty"` Value *string `json:"value,omitempty"` } +// ParametersValueFileInfo is a file containing a set of parameter values for +// an ARM template. +type ParametersValueFileInfo struct { + FileName *string `json:"fileName,omitempty"` + ParametersValueInfo *map[string]interface{} `json:"parametersValueInfo,omitempty"` +} + +// PercentageCostThresholdProperties is properties of a percentage cost +// threshold. +type PercentageCostThresholdProperties struct { + ThresholdValue *float64 `json:"thresholdValue,omitempty"` +} + // Policy is a Policy. type Policy struct { autorest.Response `json:"-"` - *PolicyProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *PolicyProperties `json:"properties,omitempty"` +} + +// PolicyFragment is a Policy. +type PolicyFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *PolicyPropertiesFragment `json:"properties,omitempty"` } // PolicyProperties is properties of a Policy. type PolicyProperties struct { + Description *string `json:"description,omitempty"` + Status PolicyStatus `json:"status,omitempty"` + FactName PolicyFactName `json:"factName,omitempty"` + FactData *string `json:"factData,omitempty"` + Threshold *string `json:"threshold,omitempty"` + EvaluatorType PolicyEvaluatorType `json:"evaluatorType,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// PolicyPropertiesFragment is properties of a Policy. +type PolicyPropertiesFragment struct { Description *string `json:"description,omitempty"` Status PolicyStatus `json:"status,omitempty"` FactName PolicyFactName `json:"factName,omitempty"` @@ -555,15 +1284,44 @@ type PolicyViolation struct { Message *string `json:"message,omitempty"` } -// ResourceCostProperties is the properties of a resource cost item. -type ResourceCostProperties struct { - Resourcename *string `json:"resourcename,omitempty"` - ResourceGroupName *string `json:"resourceGroupName,omitempty"` - ResourceCost *float64 `json:"resourceCost,omitempty"` - Owner *string `json:"owner,omitempty"` - Category *string `json:"category,omitempty"` - Exists *bool `json:"exists,omitempty"` - ResourceType *string `json:"resourceType,omitempty"` +// Port is properties of a network port. +type Port struct { + TransportProtocol TransportProtocol `json:"transportProtocol,omitempty"` + BackendPort *int32 `json:"backendPort,omitempty"` +} + +// PortFragment is properties of a network port. +type PortFragment struct { + TransportProtocol TransportProtocol `json:"transportProtocol,omitempty"` + BackendPort *int32 `json:"backendPort,omitempty"` +} + +// Resource is an Azure resource. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ResponseWithContinuationArmTemplate is the response of a list operation. +type ResponseWithContinuationArmTemplate struct { + autorest.Response `json:"-"` + Value *[]ArmTemplate `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ResponseWithContinuationArmTemplatePreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResponseWithContinuationArmTemplate) ResponseWithContinuationArmTemplatePreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) } // ResponseWithContinuationArtifact is the response of a list operation. @@ -623,6 +1381,44 @@ func (client ResponseWithContinuationCustomImage) ResponseWithContinuationCustom autorest.WithBaseURL(to.String(client.NextLink))) } +// ResponseWithContinuationDisk is the response of a list operation. +type ResponseWithContinuationDisk struct { + autorest.Response `json:"-"` + Value *[]Disk `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ResponseWithContinuationDiskPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResponseWithContinuationDisk) ResponseWithContinuationDiskPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ResponseWithContinuationDtlEnvironment is the response of a list operation. +type ResponseWithContinuationDtlEnvironment struct { + autorest.Response `json:"-"` + Value *[]DtlEnvironment `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ResponseWithContinuationDtlEnvironmentPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResponseWithContinuationDtlEnvironment) ResponseWithContinuationDtlEnvironmentPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + // ResponseWithContinuationFormula is the response of a list operation. type ResponseWithContinuationFormula struct { autorest.Response `json:"-"` @@ -719,6 +1515,26 @@ func (client ResponseWithContinuationLabVirtualMachine) ResponseWithContinuation autorest.WithBaseURL(to.String(client.NextLink))) } +// ResponseWithContinuationNotificationChannel is the response of a list +// operation. +type ResponseWithContinuationNotificationChannel struct { + autorest.Response `json:"-"` + Value *[]NotificationChannel `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ResponseWithContinuationNotificationChannelPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResponseWithContinuationNotificationChannel) ResponseWithContinuationNotificationChannelPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + // ResponseWithContinuationPolicy is the response of a list operation. type ResponseWithContinuationPolicy struct { autorest.Response `json:"-"` @@ -757,6 +1573,63 @@ func (client ResponseWithContinuationSchedule) ResponseWithContinuationScheduleP autorest.WithBaseURL(to.String(client.NextLink))) } +// ResponseWithContinuationSecret is the response of a list operation. +type ResponseWithContinuationSecret struct { + autorest.Response `json:"-"` + Value *[]Secret `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ResponseWithContinuationSecretPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResponseWithContinuationSecret) ResponseWithContinuationSecretPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ResponseWithContinuationServiceRunner is the response of a list operation. +type ResponseWithContinuationServiceRunner struct { + autorest.Response `json:"-"` + Value *[]ServiceRunner `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ResponseWithContinuationServiceRunnerPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResponseWithContinuationServiceRunner) ResponseWithContinuationServiceRunnerPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ResponseWithContinuationUser is the response of a list operation. +type ResponseWithContinuationUser struct { + autorest.Response `json:"-"` + Value *[]User `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ResponseWithContinuationUserPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ResponseWithContinuationUser) ResponseWithContinuationUserPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + // ResponseWithContinuationVirtualNetwork is the response of a list operation. type ResponseWithContinuationVirtualNetwork struct { autorest.Response `json:"-"` @@ -776,65 +1649,266 @@ func (client ResponseWithContinuationVirtualNetwork) ResponseWithContinuationVir autorest.WithBaseURL(to.String(client.NextLink))) } +// RetargetScheduleProperties is properties for retargeting a virtual machine +// schedule. +type RetargetScheduleProperties struct { + CurrentResourceID *string `json:"currentResourceId,omitempty"` + TargetResourceID *string `json:"targetResourceId,omitempty"` +} + // Schedule is a schedule. type Schedule struct { autorest.Response `json:"-"` - *ScheduleProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *ScheduleProperties `json:"properties,omitempty"` +} + +// ScheduleFragment is a schedule. +type ScheduleFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *SchedulePropertiesFragment `json:"properties,omitempty"` } // ScheduleProperties is properties of a schedule. type ScheduleProperties struct { - Status EnableStatus `json:"status,omitempty"` - TaskType *string `json:"taskType,omitempty"` - WeeklyRecurrence *WeekDetails `json:"weeklyRecurrence,omitempty"` - DailyRecurrence *DayDetails `json:"dailyRecurrence,omitempty"` - HourlyRecurrence *HourDetails `json:"hourlyRecurrence,omitempty"` - TimeZoneID *string `json:"timeZoneId,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` - UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` + Status EnableStatus `json:"status,omitempty"` + TaskType *string `json:"taskType,omitempty"` + WeeklyRecurrence *WeekDetails `json:"weeklyRecurrence,omitempty"` + DailyRecurrence *DayDetails `json:"dailyRecurrence,omitempty"` + HourlyRecurrence *HourDetails `json:"hourlyRecurrence,omitempty"` + TimeZoneID *string `json:"timeZoneId,omitempty"` + NotificationSettings *NotificationSettings `json:"notificationSettings,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + TargetResourceID *string `json:"targetResourceId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// SchedulePropertiesFragment is properties of a schedule. +type SchedulePropertiesFragment struct { + Status EnableStatus `json:"status,omitempty"` + TaskType *string `json:"taskType,omitempty"` + WeeklyRecurrence *WeekDetailsFragment `json:"weeklyRecurrence,omitempty"` + DailyRecurrence *DayDetailsFragment `json:"dailyRecurrence,omitempty"` + HourlyRecurrence *HourDetailsFragment `json:"hourlyRecurrence,omitempty"` + TimeZoneID *string `json:"timeZoneId,omitempty"` + NotificationSettings *NotificationSettingsFragment `json:"notificationSettings,omitempty"` + TargetResourceID *string `json:"targetResourceId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// Secret is a secret. +type Secret struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *SecretProperties `json:"properties,omitempty"` +} + +// SecretProperties is properties of a secret. +type SecretProperties struct { + Value *string `json:"value,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// ServiceRunner is a container for a managed identity to execute DevTest lab +// services. +type ServiceRunner struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Identity *IdentityProperties `json:"identity,omitempty"` +} + +// SharedPublicIPAddressConfiguration is properties of a virtual machine that +// determine how it is connected to a load balancer. +type SharedPublicIPAddressConfiguration struct { + InboundNatRules *[]InboundNatRule `json:"inboundNatRules,omitempty"` +} + +// SharedPublicIPAddressConfigurationFragment is properties of a virtual +// machine that determine how it is connected to a load balancer. +type SharedPublicIPAddressConfigurationFragment struct { + InboundNatRules *[]InboundNatRuleFragment `json:"inboundNatRules,omitempty"` } -// Subnet is +// ShutdownNotificationContent is the contents of a shutdown notification. +// Webhooks can use this type to deserialize the request body when they get +// notified of an imminent shutdown. +type ShutdownNotificationContent struct { + SkipURL *string `json:"skipUrl,omitempty"` + DelayURL60 *string `json:"delayUrl60,omitempty"` + DelayURL120 *string `json:"delayUrl120,omitempty"` + VMName *string `json:"vmName,omitempty"` + GUID *string `json:"guid,omitempty"` + Owner *string `json:"owner,omitempty"` + EventType *string `json:"eventType,omitempty"` + Text *string `json:"text,omitempty"` + SubscriptionID *string `json:"subscriptionId,omitempty"` + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + LabName *string `json:"labName,omitempty"` +} + +// Subnet is subnet information. type Subnet struct { ResourceID *string `json:"resourceId,omitempty"` LabSubnetName *string `json:"labSubnetName,omitempty"` AllowPublicIP UsagePermissionType `json:"allowPublicIp,omitempty"` } +// SubnetFragment is subnet information. +type SubnetFragment struct { + ResourceID *string `json:"resourceId,omitempty"` + LabSubnetName *string `json:"labSubnetName,omitempty"` + AllowPublicIP UsagePermissionType `json:"allowPublicIp,omitempty"` +} + // SubnetOverride is property overrides on a subnet of a virtual network. type SubnetOverride struct { - ResourceID *string `json:"resourceId,omitempty"` - LabSubnetName *string `json:"labSubnetName,omitempty"` - UseInVMCreationPermission UsagePermissionType `json:"useInVmCreationPermission,omitempty"` - UsePublicIPAddressPermission UsagePermissionType `json:"usePublicIpAddressPermission,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + LabSubnetName *string `json:"labSubnetName,omitempty"` + UseInVMCreationPermission UsagePermissionType `json:"useInVmCreationPermission,omitempty"` + UsePublicIPAddressPermission UsagePermissionType `json:"usePublicIpAddressPermission,omitempty"` + SharedPublicIPAddressConfiguration *SubnetSharedPublicIPAddressConfiguration `json:"sharedPublicIpAddressConfiguration,omitempty"` + VirtualNetworkPoolName *string `json:"virtualNetworkPoolName,omitempty"` +} + +// SubnetOverrideFragment is property overrides on a subnet of a virtual +// network. +type SubnetOverrideFragment struct { + ResourceID *string `json:"resourceId,omitempty"` + LabSubnetName *string `json:"labSubnetName,omitempty"` + UseInVMCreationPermission UsagePermissionType `json:"useInVmCreationPermission,omitempty"` + UsePublicIPAddressPermission UsagePermissionType `json:"usePublicIpAddressPermission,omitempty"` + SharedPublicIPAddressConfiguration *SubnetSharedPublicIPAddressConfigurationFragment `json:"sharedPublicIpAddressConfiguration,omitempty"` + VirtualNetworkPoolName *string `json:"virtualNetworkPoolName,omitempty"` +} + +// SubnetSharedPublicIPAddressConfiguration is configuration for public IP +// address sharing. +type SubnetSharedPublicIPAddressConfiguration struct { + AllowedPorts *[]Port `json:"allowedPorts,omitempty"` +} + +// SubnetSharedPublicIPAddressConfigurationFragment is configuration for public +// IP address sharing. +type SubnetSharedPublicIPAddressConfigurationFragment struct { + AllowedPorts *[]PortFragment `json:"allowedPorts,omitempty"` +} + +// TargetCostProperties is properties of a cost target. +type TargetCostProperties struct { + Status TargetCostStatus `json:"status,omitempty"` + Target *int32 `json:"target,omitempty"` + CostThresholds *[]CostThresholdProperties `json:"costThresholds,omitempty"` + CycleStartDateTime *date.Time `json:"cycleStartDateTime,omitempty"` + CycleEndDateTime *date.Time `json:"cycleEndDateTime,omitempty"` + CycleType ReportingCycleType `json:"cycleType,omitempty"` } -// SubscriptionNotification is -type SubscriptionNotification struct { - RegistrationDate *string `json:"registrationDate,omitempty"` - State SubscriptionNotificationState `json:"state,omitempty"` - Properties *SubscriptionNotificationProperties `json:"properties,omitempty"` +// User is profile of a lab user. +type User struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *UserProperties `json:"properties,omitempty"` } -// SubscriptionNotificationProperties is -type SubscriptionNotificationProperties struct { - TenantID *string `json:"tenantId,omitempty"` +// UserFragment is profile of a lab user. +type UserFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *UserPropertiesFragment `json:"properties,omitempty"` +} + +// UserIdentity is identity attributes of a lab user. +type UserIdentity struct { + PrincipalName *string `json:"principalName,omitempty"` + PrincipalID *string `json:"principalId,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + ObjectID *string `json:"objectId,omitempty"` + AppID *string `json:"appId,omitempty"` +} + +// UserIdentityFragment is identity attributes of a lab user. +type UserIdentityFragment struct { + PrincipalName *string `json:"principalName,omitempty"` + PrincipalID *string `json:"principalId,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + ObjectID *string `json:"objectId,omitempty"` + AppID *string `json:"appId,omitempty"` +} + +// UserProperties is properties of a lab user profile. +type UserProperties struct { + Identity *UserIdentity `json:"identity,omitempty"` + SecretStore *UserSecretStore `json:"secretStore,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// UserPropertiesFragment is properties of a lab user profile. +type UserPropertiesFragment struct { + Identity *UserIdentityFragment `json:"identity,omitempty"` + SecretStore *UserSecretStoreFragment `json:"secretStore,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + +// UserSecretStore is properties of a user's secret store. +type UserSecretStore struct { + KeyVaultURI *string `json:"keyVaultUri,omitempty"` + KeyVaultID *string `json:"keyVaultId,omitempty"` +} + +// UserSecretStoreFragment is properties of a user's secret store. +type UserSecretStoreFragment struct { + KeyVaultURI *string `json:"keyVaultUri,omitempty"` + KeyVaultID *string `json:"keyVaultId,omitempty"` } // VirtualNetwork is a virtual network. type VirtualNetwork struct { autorest.Response `json:"-"` - *VirtualNetworkProperties `json:"properties,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + *VirtualNetworkProperties `json:"properties,omitempty"` +} + +// VirtualNetworkFragment is a virtual network. +type VirtualNetworkFragment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *VirtualNetworkPropertiesFragment `json:"properties,omitempty"` } // VirtualNetworkProperties is properties of a virtual network. @@ -842,17 +1916,36 @@ type VirtualNetworkProperties struct { AllowedSubnets *[]Subnet `json:"allowedSubnets,omitempty"` Description *string `json:"description,omitempty"` ExternalProviderResourceID *string `json:"externalProviderResourceId,omitempty"` + ExternalSubnets *[]ExternalSubnet `json:"externalSubnets,omitempty"` SubnetOverrides *[]SubnetOverride `json:"subnetOverrides,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` } +// VirtualNetworkPropertiesFragment is properties of a virtual network. +type VirtualNetworkPropertiesFragment struct { + AllowedSubnets *[]SubnetFragment `json:"allowedSubnets,omitempty"` + Description *string `json:"description,omitempty"` + ExternalProviderResourceID *string `json:"externalProviderResourceId,omitempty"` + ExternalSubnets *[]ExternalSubnetFragment `json:"externalSubnets,omitempty"` + SubnetOverrides *[]SubnetOverrideFragment `json:"subnetOverrides,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UniqueIdentifier *string `json:"uniqueIdentifier,omitempty"` +} + // WeekDetails is properties of a weekly schedule. type WeekDetails struct { Weekdays *[]string `json:"weekdays,omitempty"` Time *string `json:"time,omitempty"` } +// WeekDetailsFragment is properties of a weekly schedule. +type WeekDetailsFragment struct { + Weekdays *[]string `json:"weekdays,omitempty"` + Time *string `json:"time,omitempty"` +} + // WindowsOsInfo is information about a Windows OS. type WindowsOsInfo struct { WindowsOsState WindowsOsState `json:"windowsOsState,omitempty"` diff --git a/arm/devtestlabs/notificationchannels.go b/arm/devtestlabs/notificationchannels.go new file mode 100644 index 000000000000..f9acf5b38e2b --- /dev/null +++ b/arm/devtestlabs/notificationchannels.go @@ -0,0 +1,501 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// NotificationChannelsClient is the the DevTest Labs Client. +type NotificationChannelsClient struct { + ManagementClient +} + +// NewNotificationChannelsClient creates an instance of the +// NotificationChannelsClient client. +func NewNotificationChannelsClient(subscriptionID string) NotificationChannelsClient { + return NewNotificationChannelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNotificationChannelsClientWithBaseURI creates an instance of the +// NotificationChannelsClient client. +func NewNotificationChannelsClientWithBaseURI(baseURI string, subscriptionID string) NotificationChannelsClient { + return NotificationChannelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing notificationChannel. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the notificationChannel. notificationChannel is +// a notification. +func (client NotificationChannelsClient) CreateOrUpdate(resourceGroupName string, labName string, name string, notificationChannel NotificationChannel) (result NotificationChannel, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: notificationChannel, + Constraints: []validation.Constraint{{Target: "notificationChannel.NotificationChannelProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.NotificationChannelsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, notificationChannel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NotificationChannelsClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, notificationChannel NotificationChannel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters), + autorest.WithJSON(notificationChannel), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationChannelsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NotificationChannelsClient) CreateOrUpdateResponder(resp *http.Response) (result NotificationChannel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete notificationchannel. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the notificationChannel. +func (client NotificationChannelsClient) Delete(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NotificationChannelsClient) DeletePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationChannelsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NotificationChannelsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get notificationchannel. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the notificationChannel. expand is specify the +// $expand query. Example: 'properties($select=webHookUrl)' +func (client NotificationChannelsClient) Get(resourceGroupName string, labName string, name string, expand string) (result NotificationChannel, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NotificationChannelsClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationChannelsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NotificationChannelsClient) GetResponder(resp *http.Response) (result NotificationChannel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list notificationchannels in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. expand is specify the $expand query. Example: +// 'properties($select=webHookUrl)' filter is the filter to apply to the +// operation. top is the maximum number of resources to return from the +// operation. orderby is the ordering expression for the results, using OData +// notation. +func (client NotificationChannelsClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationNotificationChannel, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client NotificationChannelsClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationChannelsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client NotificationChannelsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationNotificationChannel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client NotificationChannelsClient) ListNextResults(lastResults ResponseWithContinuationNotificationChannel) (result ResponseWithContinuationNotificationChannel, err error) { + req, err := lastResults.ResponseWithContinuationNotificationChannelPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// Notify send notification to provided channel. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the notificationChannel. notifyParameters is +// properties for generating a Notification. +func (client NotificationChannelsClient) Notify(resourceGroupName string, labName string, name string, notifyParameters NotifyParameters) (result autorest.Response, err error) { + req, err := client.NotifyPreparer(resourceGroupName, labName, name, notifyParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Notify", nil, "Failure preparing request") + return + } + + resp, err := client.NotifySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Notify", resp, "Failure sending request") + return + } + + result, err = client.NotifyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Notify", resp, "Failure responding to request") + } + + return +} + +// NotifyPreparer prepares the Notify request. +func (client NotificationChannelsClient) NotifyPreparer(resourceGroupName string, labName string, name string, notifyParameters NotifyParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}/notify", pathParameters), + autorest.WithJSON(notifyParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// NotifySender sends the Notify request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationChannelsClient) NotifySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// NotifyResponder handles the response to the Notify request. The method always +// closes the http.Response Body. +func (client NotificationChannelsClient) NotifyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update modify properties of notificationchannels. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the notificationChannel. notificationChannel is +// a notification. +func (client NotificationChannelsClient) Update(resourceGroupName string, labName string, name string, notificationChannel NotificationChannelFragment) (result NotificationChannel, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, name, notificationChannel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.NotificationChannelsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client NotificationChannelsClient) UpdatePreparer(resourceGroupName string, labName string, name string, notificationChannel NotificationChannelFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/notificationchannels/{name}", pathParameters), + autorest.WithJSON(notificationChannel), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationChannelsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client NotificationChannelsClient) UpdateResponder(resp *http.Response) (result NotificationChannel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/policyoperations.go b/arm/devtestlabs/policies.go similarity index 51% rename from arm/devtestlabs/policyoperations.go rename to arm/devtestlabs/policies.go index 64eb3f5d6d51..7405b86e1b08 100644 --- a/arm/devtestlabs/policyoperations.go +++ b/arm/devtestlabs/policies.go @@ -14,60 +14,68 @@ package devtestlabs // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" "net/http" ) -// PolicyOperationsClient is the azure DevTest Labs REST API. -type PolicyOperationsClient struct { +// PoliciesClient is the the DevTest Labs Client. +type PoliciesClient struct { ManagementClient } -// NewPolicyOperationsClient creates an instance of the PolicyOperationsClient -// client. -func NewPolicyOperationsClient(subscriptionID string) PolicyOperationsClient { - return NewPolicyOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +// NewPoliciesClient creates an instance of the PoliciesClient client. +func NewPoliciesClient(subscriptionID string) PoliciesClient { + return NewPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewPolicyOperationsClientWithBaseURI creates an instance of the -// PolicyOperationsClient client. -func NewPolicyOperationsClientWithBaseURI(baseURI string, subscriptionID string) PolicyOperationsClient { - return PolicyOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +// NewPoliciesClientWithBaseURI creates an instance of the PoliciesClient +// client. +func NewPoliciesClientWithBaseURI(baseURI string, subscriptionID string) PoliciesClient { + return PoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdateResource create or replace an existing policy. +// CreateOrUpdate create or replace an existing policy. // // resourceGroupName is the name of the resource group. labName is the name of // the lab. policySetName is the name of the policy set. name is the name of -// the policy. -func (client PolicyOperationsClient) CreateOrUpdateResource(resourceGroupName string, labName string, policySetName string, name string, policy Policy) (result Policy, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, labName, policySetName, name, policy) +// the policy. policy is a Policy. +func (client PoliciesClient) CreateOrUpdate(resourceGroupName string, labName string, policySetName string, name string, policy Policy) (result Policy, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: policy, + Constraints: []validation.Constraint{{Target: "policy.PolicyProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.PoliciesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, policySetName, name, policy) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "CreateOrUpdateResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } - resp, err := client.CreateOrUpdateResourceSender(req) + resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "CreateOrUpdateResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return } - result, err = client.CreateOrUpdateResourceResponder(resp) + result, err = client.CreateOrUpdateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "CreateOrUpdateResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") } return } -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client PolicyOperationsClient) CreateOrUpdateResourcePreparer(resourceGroupName string, labName string, policySetName string, name string, policy Policy) (*http.Request, error) { +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PoliciesClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, policySetName string, name string, policy Policy) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -76,8 +84,9 @@ func (client PolicyOperationsClient) CreateOrUpdateResourcePreparer(resourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -90,15 +99,15 @@ func (client PolicyOperationsClient) CreateOrUpdateResourcePreparer(resourceGrou return preparer.Prepare(&http.Request{}) } -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. -func (client PolicyOperationsClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { +func (client PoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client PolicyOperationsClient) CreateOrUpdateResourceResponder(resp *http.Response) (result Policy, err error) { +func (client PoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result Policy, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -109,33 +118,35 @@ func (client PolicyOperationsClient) CreateOrUpdateResourceResponder(resp *http. return } -// DeleteResource delete policy. +// Delete delete policy. // // resourceGroupName is the name of the resource group. labName is the name of // the lab. policySetName is the name of the policy set. name is the name of // the policy. -func (client PolicyOperationsClient) DeleteResource(resourceGroupName string, labName string, policySetName string, name string) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, labName, policySetName, name) +func (client PoliciesClient) Delete(resourceGroupName string, labName string, policySetName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, policySetName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "DeleteResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Delete", nil, "Failure preparing request") + return } - resp, err := client.DeleteResourceSender(req) + resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "DeleteResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Delete", resp, "Failure sending request") + return } - result, err = client.DeleteResourceResponder(resp) + result, err = client.DeleteResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "DeleteResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Delete", resp, "Failure responding to request") } return } -// DeleteResourcePreparer prepares the DeleteResource request. -func (client PolicyOperationsClient) DeleteResourcePreparer(resourceGroupName string, labName string, policySetName string, name string) (*http.Request, error) { +// DeletePreparer prepares the Delete request. +func (client PoliciesClient) DeletePreparer(resourceGroupName string, labName string, policySetName string, name string) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -144,8 +155,9 @@ func (client PolicyOperationsClient) DeleteResourcePreparer(resourceGroupName st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -156,15 +168,15 @@ func (client PolicyOperationsClient) DeleteResourcePreparer(resourceGroupName st return preparer.Prepare(&http.Request{}) } -// DeleteResourceSender sends the DeleteResource request. The method will close the +// DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. -func (client PolicyOperationsClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { +func (client PoliciesClient) DeleteSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// DeleteResourceResponder handles the response to the DeleteResource request. The method always +// DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client PolicyOperationsClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { +func (client PoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -174,33 +186,36 @@ func (client PolicyOperationsClient) DeleteResourceResponder(resp *http.Response return } -// GetResource get policy. +// Get get policy. // // resourceGroupName is the name of the resource group. labName is the name of // the lab. policySetName is the name of the policy set. name is the name of -// the policy. -func (client PolicyOperationsClient) GetResource(resourceGroupName string, labName string, policySetName string, name string) (result Policy, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, policySetName, name) +// the policy. expand is specify the $expand query. Example: +// 'properties($select=description)' +func (client PoliciesClient) Get(resourceGroupName string, labName string, policySetName string, name string, expand string) (result Policy, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, policySetName, name, expand) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "GetResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Get", nil, "Failure preparing request") + return } - resp, err := client.GetResourceSender(req) + resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "GetResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Get", resp, "Failure sending request") + return } - result, err = client.GetResourceResponder(resp) + result, err = client.GetResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "GetResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Get", resp, "Failure responding to request") } return } -// GetResourcePreparer prepares the GetResource request. -func (client PolicyOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, policySetName string, name string) (*http.Request, error) { +// GetPreparer prepares the Get request. +func (client PoliciesClient) GetPreparer(resourceGroupName string, labName string, policySetName string, name string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -209,8 +224,12 @@ func (client PolicyOperationsClient) GetResourcePreparer(resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } preparer := autorest.CreatePreparer( @@ -221,15 +240,15 @@ func (client PolicyOperationsClient) GetResourcePreparer(resourceGroupName strin return preparer.Prepare(&http.Request{}) } -// GetResourceSender sends the GetResource request. The method will close the +// GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. -func (client PolicyOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { +func (client PoliciesClient) GetSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// GetResourceResponder handles the response to the GetResource request. The method always +// GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client PolicyOperationsClient) GetResourceResponder(resp *http.Response) (result Policy, err error) { +func (client PoliciesClient) GetResponder(resp *http.Response) (result Policy, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -243,32 +262,35 @@ func (client PolicyOperationsClient) GetResourceResponder(resp *http.Response) ( // List list policies in a given policy set. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. policySetName is the name of the policy set. filter is the filter -// to apply on the operation. top is the maximum number of resources to -// return from the operation. orderBy is the ordering expression for the +// the lab. policySetName is the name of the policy set. expand is specify the +// $expand query. Example: 'properties($select=description)' filter is the +// filter to apply to the operation. top is the maximum number of resources to +// return from the operation. orderby is the ordering expression for the // results, using OData notation. -func (client PolicyOperationsClient) List(resourceGroupName string, labName string, policySetName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationPolicy, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, policySetName, filter, top, orderBy) +func (client PoliciesClient) List(resourceGroupName string, labName string, policySetName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationPolicy, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, policySetName, expand, filter, top, orderby) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "List", resp, "Failure responding to request") } return } // ListPreparer prepares the List request. -func (client PolicyOperationsClient) ListPreparer(resourceGroupName string, labName string, policySetName string, filter string, top *int32, orderBy string) (*http.Request, error) { +func (client PoliciesClient) ListPreparer(resourceGroupName string, labName string, policySetName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "policySetName": autorest.Encode("path", policySetName), @@ -276,8 +298,12 @@ func (client PolicyOperationsClient) ListPreparer(resourceGroupName string, labN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -285,8 +311,8 @@ func (client PolicyOperationsClient) ListPreparer(resourceGroupName string, labN if top != nil { queryParameters["$top"] = autorest.Encode("query", *top) } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) } preparer := autorest.CreatePreparer( @@ -299,13 +325,13 @@ func (client PolicyOperationsClient) ListPreparer(resourceGroupName string, labN // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. -func (client PolicyOperationsClient) ListSender(req *http.Request) (*http.Response, error) { +func (client PoliciesClient) ListSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. -func (client PolicyOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationPolicy, err error) { +func (client PoliciesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationPolicy, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -317,10 +343,10 @@ func (client PolicyOperationsClient) ListResponder(resp *http.Response) (result } // ListNextResults retrieves the next set of results, if any. -func (client PolicyOperationsClient) ListNextResults(lastResults ResponseWithContinuationPolicy) (result ResponseWithContinuationPolicy, err error) { +func (client PoliciesClient) ListNextResults(lastResults ResponseWithContinuationPolicy) (result ResponseWithContinuationPolicy, err error) { req, err := lastResults.ResponseWithContinuationPolicyPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "List", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "List", nil, "Failure preparing next results request") } if req == nil { return @@ -329,44 +355,46 @@ func (client PolicyOperationsClient) ListNextResults(lastResults ResponseWithCon resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "List", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "List", resp, "Failure sending next results request") } result, err = client.ListResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "List", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "List", resp, "Failure responding to next results request") } return } -// PatchResource modify properties of policies. +// Update modify properties of policies. // // resourceGroupName is the name of the resource group. labName is the name of // the lab. policySetName is the name of the policy set. name is the name of -// the policy. -func (client PolicyOperationsClient) PatchResource(resourceGroupName string, labName string, policySetName string, name string, policy Policy) (result Policy, err error) { - req, err := client.PatchResourcePreparer(resourceGroupName, labName, policySetName, name, policy) +// the policy. policy is a Policy. +func (client PoliciesClient) Update(resourceGroupName string, labName string, policySetName string, name string, policy PolicyFragment) (result Policy, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, policySetName, name, policy) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "PatchResource", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Update", nil, "Failure preparing request") + return } - resp, err := client.PatchResourceSender(req) + resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "PatchResource", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Update", resp, "Failure sending request") + return } - result, err = client.PatchResourceResponder(resp) + result, err = client.UpdateResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.PolicyOperationsClient", "PatchResource", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.PoliciesClient", "Update", resp, "Failure responding to request") } return } -// PatchResourcePreparer prepares the PatchResource request. -func (client PolicyOperationsClient) PatchResourcePreparer(resourceGroupName string, labName string, policySetName string, name string, policy Policy) (*http.Request, error) { +// UpdatePreparer prepares the Update request. +func (client PoliciesClient) UpdatePreparer(resourceGroupName string, labName string, policySetName string, name string, policy PolicyFragment) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -375,8 +403,9 @@ func (client PolicyOperationsClient) PatchResourcePreparer(resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -389,15 +418,15 @@ func (client PolicyOperationsClient) PatchResourcePreparer(resourceGroupName str return preparer.Prepare(&http.Request{}) } -// PatchResourceSender sends the PatchResource request. The method will close the +// UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. -func (client PolicyOperationsClient) PatchResourceSender(req *http.Request) (*http.Response, error) { +func (client PoliciesClient) UpdateSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// PatchResourceResponder handles the response to the PatchResource request. The method always +// UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client PolicyOperationsClient) PatchResourceResponder(resp *http.Response) (result Policy, err error) { +func (client PoliciesClient) UpdateResponder(resp *http.Response) (result Policy, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/arm/devtestlabs/policyset.go b/arm/devtestlabs/policysets.go similarity index 59% rename from arm/devtestlabs/policyset.go rename to arm/devtestlabs/policysets.go index 22c3a7fdd988..d61065502b77 100644 --- a/arm/devtestlabs/policyset.go +++ b/arm/devtestlabs/policysets.go @@ -14,7 +14,7 @@ package devtestlabs // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -24,48 +24,51 @@ import ( "net/http" ) -// PolicySetClient is the azure DevTest Labs REST API. -type PolicySetClient struct { +// PolicySetsClient is the the DevTest Labs Client. +type PolicySetsClient struct { ManagementClient } -// NewPolicySetClient creates an instance of the PolicySetClient client. -func NewPolicySetClient(subscriptionID string) PolicySetClient { - return NewPolicySetClientWithBaseURI(DefaultBaseURI, subscriptionID) +// NewPolicySetsClient creates an instance of the PolicySetsClient client. +func NewPolicySetsClient(subscriptionID string) PolicySetsClient { + return NewPolicySetsClientWithBaseURI(DefaultBaseURI, subscriptionID) } -// NewPolicySetClientWithBaseURI creates an instance of the PolicySetClient +// NewPolicySetsClientWithBaseURI creates an instance of the PolicySetsClient // client. -func NewPolicySetClientWithBaseURI(baseURI string, subscriptionID string) PolicySetClient { - return PolicySetClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewPolicySetsClientWithBaseURI(baseURI string, subscriptionID string) PolicySetsClient { + return PolicySetsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// EvaluatePolicies evaluates Lab Policy. +// EvaluatePolicies evaluates lab policy. // // resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the policy set. -func (client PolicySetClient) EvaluatePolicies(resourceGroupName string, labName string, name string, evaluatePoliciesRequest EvaluatePoliciesRequest) (result EvaluatePoliciesResponse, err error) { +// the lab. name is the name of the policy set. evaluatePoliciesRequest is +// request body for evaluating a policy set. +func (client PolicySetsClient) EvaluatePolicies(resourceGroupName string, labName string, name string, evaluatePoliciesRequest EvaluatePoliciesRequest) (result EvaluatePoliciesResponse, err error) { req, err := client.EvaluatePoliciesPreparer(resourceGroupName, labName, name, evaluatePoliciesRequest) if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicySetClient", "EvaluatePolicies", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "devtestlabs.PolicySetsClient", "EvaluatePolicies", nil, "Failure preparing request") + return } resp, err := client.EvaluatePoliciesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.PolicySetClient", "EvaluatePolicies", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "devtestlabs.PolicySetsClient", "EvaluatePolicies", resp, "Failure sending request") + return } result, err = client.EvaluatePoliciesResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.PolicySetClient", "EvaluatePolicies", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "devtestlabs.PolicySetsClient", "EvaluatePolicies", resp, "Failure responding to request") } return } // EvaluatePoliciesPreparer prepares the EvaluatePolicies request. -func (client PolicySetClient) EvaluatePoliciesPreparer(resourceGroupName string, labName string, name string, evaluatePoliciesRequest EvaluatePoliciesRequest) (*http.Request, error) { +func (client PolicySetsClient) EvaluatePoliciesPreparer(resourceGroupName string, labName string, name string, evaluatePoliciesRequest EvaluatePoliciesRequest) (*http.Request, error) { pathParameters := map[string]interface{}{ "labName": autorest.Encode("path", labName), "name": autorest.Encode("path", name), @@ -73,8 +76,9 @@ func (client PolicySetClient) EvaluatePoliciesPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-15" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -89,13 +93,13 @@ func (client PolicySetClient) EvaluatePoliciesPreparer(resourceGroupName string, // EvaluatePoliciesSender sends the EvaluatePolicies request. The method will close the // http.Response Body if it receives an error. -func (client PolicySetClient) EvaluatePoliciesSender(req *http.Request) (*http.Response, error) { +func (client PolicySetsClient) EvaluatePoliciesSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } // EvaluatePoliciesResponder handles the response to the EvaluatePolicies request. The method always // closes the http.Response Body. -func (client PolicySetClient) EvaluatePoliciesResponder(resp *http.Response) (result EvaluatePoliciesResponse, err error) { +func (client PolicySetsClient) EvaluatePoliciesResponder(resp *http.Response) (result EvaluatePoliciesResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/arm/devtestlabs/scheduleoperations.go b/arm/devtestlabs/scheduleoperations.go deleted file mode 100644 index 2a58ed59963f..000000000000 --- a/arm/devtestlabs/scheduleoperations.go +++ /dev/null @@ -1,467 +0,0 @@ -package devtestlabs - -// Copyright (c) Microsoft and contributors. 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 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// ScheduleOperationsClient is the azure DevTest Labs REST API. -type ScheduleOperationsClient struct { - ManagementClient -} - -// NewScheduleOperationsClient creates an instance of the -// ScheduleOperationsClient client. -func NewScheduleOperationsClient(subscriptionID string) ScheduleOperationsClient { - return NewScheduleOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewScheduleOperationsClientWithBaseURI creates an instance of the -// ScheduleOperationsClient client. -func NewScheduleOperationsClientWithBaseURI(baseURI string, subscriptionID string) ScheduleOperationsClient { - return ScheduleOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdateResource create or replace an existing schedule. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the schedule. -func (client ScheduleOperationsClient) CreateOrUpdateResource(resourceGroupName string, labName string, name string, schedule Schedule) (result Schedule, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, labName, name, schedule) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "CreateOrUpdateResource", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "CreateOrUpdateResource", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "CreateOrUpdateResource", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client ScheduleOperationsClient) CreateOrUpdateResourcePreparer(resourceGroupName string, labName string, name string, schedule Schedule) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), - autorest.WithJSON(schedule), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the -// http.Response Body if it receives an error. -func (client ScheduleOperationsClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always -// closes the http.Response Body. -func (client ScheduleOperationsClient) CreateOrUpdateResourceResponder(resp *http.Response) (result Schedule, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteResource delete schedule. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the schedule. -func (client ScheduleOperationsClient) DeleteResource(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "DeleteResource", nil, "Failure preparing request") - } - - resp, err := client.DeleteResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "DeleteResource", resp, "Failure sending request") - } - - result, err = client.DeleteResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "DeleteResource", resp, "Failure responding to request") - } - - return -} - -// DeleteResourcePreparer prepares the DeleteResource request. -func (client ScheduleOperationsClient) DeleteResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// DeleteResourceSender sends the DeleteResource request. The method will close the -// http.Response Body if it receives an error. -func (client ScheduleOperationsClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// DeleteResourceResponder handles the response to the DeleteResource request. The method always -// closes the http.Response Body. -func (client ScheduleOperationsClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Execute execute a schedule. This operation can take a while to complete. -// This method may poll for completion. Polling can be canceled by passing -// the cancel channel argument. The channel will be used to cancel polling -// and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the schedule. -func (client ScheduleOperationsClient) Execute(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ExecutePreparer(resourceGroupName, labName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "Execute", nil, "Failure preparing request") - } - - resp, err := client.ExecuteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "Execute", resp, "Failure sending request") - } - - result, err = client.ExecuteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "Execute", resp, "Failure responding to request") - } - - return -} - -// ExecutePreparer prepares the Execute request. -func (client ScheduleOperationsClient) ExecutePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// ExecuteSender sends the Execute request. The method will close the -// http.Response Body if it receives an error. -func (client ScheduleOperationsClient) ExecuteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// ExecuteResponder handles the response to the Execute request. The method always -// closes the http.Response Body. -func (client ScheduleOperationsClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetResource get schedule. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the schedule. -func (client ScheduleOperationsClient) GetResource(resourceGroupName string, labName string, name string) (result Schedule, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "GetResource", nil, "Failure preparing request") - } - - resp, err := client.GetResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "GetResource", resp, "Failure sending request") - } - - result, err = client.GetResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "GetResource", resp, "Failure responding to request") - } - - return -} - -// GetResourcePreparer prepares the GetResource request. -func (client ScheduleOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetResourceSender sends the GetResource request. The method will close the -// http.Response Body if it receives an error. -func (client ScheduleOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResourceResponder handles the response to the GetResource request. The method always -// closes the http.Response Body. -func (client ScheduleOperationsClient) GetResourceResponder(resp *http.Response) (result Schedule, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list schedules in a given lab. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. filter is the filter to apply on the operation. top is the -// maximum number of resources to return from the operation. orderBy is the -// ordering expression for the results, using OData notation. -func (client ScheduleOperationsClient) List(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationSchedule, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderBy) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "List", nil, "Failure preparing request") - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "List", resp, "Failure sending request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ScheduleOperationsClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ScheduleOperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ScheduleOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationSchedule, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNextResults retrieves the next set of results, if any. -func (client ScheduleOperationsClient) ListNextResults(lastResults ResponseWithContinuationSchedule) (result ResponseWithContinuationSchedule, err error) { - req, err := lastResults.ResponseWithContinuationSchedulePreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "List", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "List", resp, "Failure sending next results request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "List", resp, "Failure responding to next results request") - } - - return -} - -// PatchResource modify properties of schedules. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the schedule. -func (client ScheduleOperationsClient) PatchResource(resourceGroupName string, labName string, name string, schedule Schedule) (result Schedule, err error) { - req, err := client.PatchResourcePreparer(resourceGroupName, labName, name, schedule) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "PatchResource", nil, "Failure preparing request") - } - - resp, err := client.PatchResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "PatchResource", resp, "Failure sending request") - } - - result, err = client.PatchResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.ScheduleOperationsClient", "PatchResource", resp, "Failure responding to request") - } - - return -} - -// PatchResourcePreparer prepares the PatchResource request. -func (client ScheduleOperationsClient) PatchResourcePreparer(resourceGroupName string, labName string, name string, schedule Schedule) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), - autorest.WithJSON(schedule), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// PatchResourceSender sends the PatchResource request. The method will close the -// http.Response Body if it receives an error. -func (client ScheduleOperationsClient) PatchResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// PatchResourceResponder handles the response to the PatchResource request. The method always -// closes the http.Response Body. -func (client ScheduleOperationsClient) PatchResourceResponder(resp *http.Response) (result Schedule, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/arm/devtestlabs/schedules.go b/arm/devtestlabs/schedules.go new file mode 100644 index 000000000000..2a8ab3335dc3 --- /dev/null +++ b/arm/devtestlabs/schedules.go @@ -0,0 +1,601 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// SchedulesClient is the the DevTest Labs Client. +type SchedulesClient struct { + ManagementClient +} + +// NewSchedulesClient creates an instance of the SchedulesClient client. +func NewSchedulesClient(subscriptionID string) SchedulesClient { + return NewSchedulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSchedulesClientWithBaseURI creates an instance of the SchedulesClient +// client. +func NewSchedulesClientWithBaseURI(baseURI string, subscriptionID string) SchedulesClient { + return SchedulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing schedule. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the schedule. schedule is a schedule. +func (client SchedulesClient) CreateOrUpdate(resourceGroupName string, labName string, name string, schedule Schedule) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: schedule, + Constraints: []validation.Constraint{{Target: "schedule.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.SchedulesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, schedule) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SchedulesClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, schedule Schedule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), + autorest.WithJSON(schedule), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SchedulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SchedulesClient) CreateOrUpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete schedule. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the schedule. +func (client SchedulesClient) Delete(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SchedulesClient) DeletePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SchedulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SchedulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Execute execute a schedule. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the schedule. +func (client SchedulesClient) Execute(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ExecutePreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Execute", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ExecutePreparer prepares the Execute request. +func (client SchedulesClient) ExecutePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client SchedulesClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client SchedulesClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get schedule. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the schedule. expand is specify the $expand +// query. Example: 'properties($select=status)' +func (client SchedulesClient) Get(resourceGroupName string, labName string, name string, expand string) (result Schedule, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SchedulesClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SchedulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SchedulesClient) GetResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list schedules in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. expand is specify the $expand query. Example: +// 'properties($select=status)' filter is the filter to apply to the operation. +// top is the maximum number of resources to return from the operation. orderby +// is the ordering expression for the results, using OData notation. +func (client SchedulesClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationSchedule, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SchedulesClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SchedulesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SchedulesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client SchedulesClient) ListNextResults(lastResults ResponseWithContinuationSchedule) (result ResponseWithContinuationSchedule, err error) { + req, err := lastResults.ResponseWithContinuationSchedulePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListApplicable lists all applicable schedules +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the schedule. +func (client SchedulesClient) ListApplicable(resourceGroupName string, labName string, name string) (result ResponseWithContinuationSchedule, err error) { + req, err := client.ListApplicablePreparer(resourceGroupName, labName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "ListApplicable", nil, "Failure preparing request") + return + } + + resp, err := client.ListApplicableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "ListApplicable", resp, "Failure sending request") + return + } + + result, err = client.ListApplicableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "ListApplicable", resp, "Failure responding to request") + } + + return +} + +// ListApplicablePreparer prepares the ListApplicable request. +func (client SchedulesClient) ListApplicablePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/listApplicable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListApplicableSender sends the ListApplicable request. The method will close the +// http.Response Body if it receives an error. +func (client SchedulesClient) ListApplicableSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListApplicableResponder handles the response to the ListApplicable request. The method always +// closes the http.Response Body. +func (client SchedulesClient) ListApplicableResponder(resp *http.Response) (result ResponseWithContinuationSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListApplicableNextResults retrieves the next set of results, if any. +func (client SchedulesClient) ListApplicableNextResults(lastResults ResponseWithContinuationSchedule) (result ResponseWithContinuationSchedule, err error) { + req, err := lastResults.ResponseWithContinuationSchedulePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "ListApplicable", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListApplicableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "ListApplicable", resp, "Failure sending next results request") + } + + result, err = client.ListApplicableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "ListApplicable", resp, "Failure responding to next results request") + } + + return +} + +// Update modify properties of schedules. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the schedule. schedule is a schedule. +func (client SchedulesClient) Update(resourceGroupName string, labName string, name string, schedule ScheduleFragment) (result Schedule, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, name, schedule) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SchedulesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SchedulesClient) UpdatePreparer(resourceGroupName string, labName string, name string, schedule ScheduleFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters), + autorest.WithJSON(schedule), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SchedulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SchedulesClient) UpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/secrets.go b/arm/devtestlabs/secrets.go new file mode 100644 index 000000000000..598a7d065250 --- /dev/null +++ b/arm/devtestlabs/secrets.go @@ -0,0 +1,366 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// SecretsClient is the the DevTest Labs Client. +type SecretsClient struct { + ManagementClient +} + +// NewSecretsClient creates an instance of the SecretsClient client. +func NewSecretsClient(subscriptionID string) SecretsClient { + return NewSecretsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSecretsClientWithBaseURI creates an instance of the SecretsClient client. +func NewSecretsClientWithBaseURI(baseURI string, subscriptionID string) SecretsClient { + return SecretsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing secret. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// secret. secret is a secret. +func (client SecretsClient) CreateOrUpdate(resourceGroupName string, labName string, userName string, name string, secret Secret) (result Secret, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: secret, + Constraints: []validation.Constraint{{Target: "secret.SecretProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.SecretsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, userName, name, secret) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SecretsClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, userName string, name string, secret Secret) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}", pathParameters), + autorest.WithJSON(secret), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SecretsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SecretsClient) CreateOrUpdateResponder(resp *http.Response) (result Secret, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete secret. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// secret. +func (client SecretsClient) Delete(resourceGroupName string, labName string, userName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, userName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SecretsClient) DeletePreparer(resourceGroupName string, labName string, userName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SecretsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SecretsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get secret. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. name is the name of the +// secret. expand is specify the $expand query. Example: +// 'properties($select=value)' +func (client SecretsClient) Get(resourceGroupName string, labName string, userName string, name string, expand string) (result Secret, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, userName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SecretsClient) GetPreparer(resourceGroupName string, labName string, userName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SecretsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SecretsClient) GetResponder(resp *http.Response) (result Secret, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list secrets in a given user profile. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. userName is the name of the user profile. expand is specify the +// $expand query. Example: 'properties($select=value)' filter is the filter to +// apply to the operation. top is the maximum number of resources to return +// from the operation. orderby is the ordering expression for the results, +// using OData notation. +func (client SecretsClient) List(resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationSecret, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, userName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SecretsClient) ListPreparer(resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userName": autorest.Encode("path", userName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/secrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SecretsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SecretsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationSecret, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client SecretsClient) ListNextResults(lastResults ResponseWithContinuationSecret) (result ResponseWithContinuationSecret, err error) { + req, err := lastResults.ResponseWithContinuationSecretPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.SecretsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/devtestlabs/servicerunners.go b/arm/devtestlabs/servicerunners.go new file mode 100644 index 000000000000..5f473b636d2b --- /dev/null +++ b/arm/devtestlabs/servicerunners.go @@ -0,0 +1,346 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ServiceRunnersClient is the the DevTest Labs Client. +type ServiceRunnersClient struct { + ManagementClient +} + +// NewServiceRunnersClient creates an instance of the ServiceRunnersClient +// client. +func NewServiceRunnersClient(subscriptionID string) ServiceRunnersClient { + return NewServiceRunnersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceRunnersClientWithBaseURI creates an instance of the +// ServiceRunnersClient client. +func NewServiceRunnersClientWithBaseURI(baseURI string, subscriptionID string) ServiceRunnersClient { + return ServiceRunnersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing Service runner. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the service runner. serviceRunner is a +// container for a managed identity to execute DevTest lab services. +func (client ServiceRunnersClient) CreateOrUpdate(resourceGroupName string, labName string, name string, serviceRunner ServiceRunner) (result ServiceRunner, err error) { + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, serviceRunner) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServiceRunnersClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, serviceRunner ServiceRunner) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}", pathParameters), + autorest.WithJSON(serviceRunner), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceRunnersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServiceRunnersClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceRunner, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete service runner. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the service runner. +func (client ServiceRunnersClient) Delete(resourceGroupName string, labName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServiceRunnersClient) DeletePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceRunnersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServiceRunnersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get service runner. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the service runner. +func (client ServiceRunnersClient) Get(resourceGroupName string, labName string, name string) (result ServiceRunner, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceRunnersClient) GetPreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceRunnersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceRunnersClient) GetResponder(resp *http.Response) (result ServiceRunner, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list service runners in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. filter is the filter to apply to the operation. top is the maximum +// number of resources to return from the operation. orderby is the ordering +// expression for the results, using OData notation. +func (client ServiceRunnersClient) List(resourceGroupName string, labName string, filter string, top *int32, orderby string) (result ResponseWithContinuationServiceRunner, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceRunnersClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/servicerunners", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceRunnersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceRunnersClient) ListResponder(resp *http.Response) (result ResponseWithContinuationServiceRunner, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ServiceRunnersClient) ListNextResults(lastResults ResponseWithContinuationServiceRunner) (result ResponseWithContinuationServiceRunner, err error) { + req, err := lastResults.ResponseWithContinuationServiceRunnerPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.ServiceRunnersClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/devtestlabs/users.go b/arm/devtestlabs/users.go new file mode 100644 index 000000000000..86c22e8de52c --- /dev/null +++ b/arm/devtestlabs/users.go @@ -0,0 +1,439 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// UsersClient is the the DevTest Labs Client. +type UsersClient struct { + ManagementClient +} + +// NewUsersClient creates an instance of the UsersClient client. +func NewUsersClient(subscriptionID string) UsersClient { + return NewUsersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsersClientWithBaseURI creates an instance of the UsersClient client. +func NewUsersClientWithBaseURI(baseURI string, subscriptionID string) UsersClient { + return UsersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing user profile. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the user profile. userParameter is profile of a +// lab user. +func (client UsersClient) CreateOrUpdate(resourceGroupName string, labName string, name string, userParameter User) (result User, err error) { + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, userParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client UsersClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, userParameter User) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}", pathParameters), + autorest.WithJSON(userParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client UsersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client UsersClient) CreateOrUpdateResponder(resp *http.Response) (result User, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete user profile. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the user profile. +func (client UsersClient) Delete(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client UsersClient) DeletePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client UsersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client UsersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get user profile. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the user profile. expand is specify the $expand +// query. Example: 'properties($select=identity)' +func (client UsersClient) Get(resourceGroupName string, labName string, name string, expand string) (result User, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client UsersClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client UsersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client UsersClient) GetResponder(resp *http.Response) (result User, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list user profiles in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. expand is specify the $expand query. Example: +// 'properties($select=identity)' filter is the filter to apply to the +// operation. top is the maximum number of resources to return from the +// operation. orderby is the ordering expression for the results, using OData +// notation. +func (client UsersClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationUser, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client UsersClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UsersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UsersClient) ListResponder(resp *http.Response) (result ResponseWithContinuationUser, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client UsersClient) ListNextResults(lastResults ResponseWithContinuationUser) (result ResponseWithContinuationUser, err error) { + req, err := lastResults.ResponseWithContinuationUserPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// Update modify properties of user profiles. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the user profile. userParameter is profile of a +// lab user. +func (client UsersClient) Update(resourceGroupName string, labName string, name string, userParameter UserFragment) (result User, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, name, userParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.UsersClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client UsersClient) UpdatePreparer(resourceGroupName string, labName string, name string, userParameter UserFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{name}", pathParameters), + autorest.WithJSON(userParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client UsersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client UsersClient) UpdateResponder(resp *http.Response) (result User, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/version.go b/arm/devtestlabs/version.go index 6d7fade58d46..e233adc19ca3 100644 --- a/arm/devtestlabs/version.go +++ b/arm/devtestlabs/version.go @@ -18,43 +18,12 @@ package devtestlabs // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "devtestlabs", "2016-05-15") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.0-beta arm-devtestlabs/2016-05-15" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.0-beta" } diff --git a/arm/devtestlabs/virtualmachine.go b/arm/devtestlabs/virtualmachine.go deleted file mode 100644 index 144038ef3e2b..000000000000 --- a/arm/devtestlabs/virtualmachine.go +++ /dev/null @@ -1,615 +0,0 @@ -package devtestlabs - -// Copyright (c) Microsoft and contributors. 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 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// VirtualMachineClient is the azure DevTest Labs REST API. -type VirtualMachineClient struct { - ManagementClient -} - -// NewVirtualMachineClient creates an instance of the VirtualMachineClient -// client. -func NewVirtualMachineClient(subscriptionID string) VirtualMachineClient { - return NewVirtualMachineClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewVirtualMachineClientWithBaseURI creates an instance of the -// VirtualMachineClient client. -func NewVirtualMachineClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineClient { - return VirtualMachineClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ApplyArtifacts apply artifacts to Lab VM. This operation can take a while -// to complete. This method may poll for completion. Polling can be canceled -// by passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual Machine. -func (client VirtualMachineClient) ApplyArtifacts(resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.ApplyArtifactsPreparer(resourceGroupName, labName, name, applyArtifactsRequest, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "ApplyArtifacts", nil, "Failure preparing request") - } - - resp, err := client.ApplyArtifactsSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "ApplyArtifacts", resp, "Failure sending request") - } - - result, err = client.ApplyArtifactsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "ApplyArtifacts", resp, "Failure responding to request") - } - - return -} - -// ApplyArtifactsPreparer prepares the ApplyArtifacts request. -func (client VirtualMachineClient) ApplyArtifactsPreparer(resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts", pathParameters), - autorest.WithJSON(applyArtifactsRequest), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// ApplyArtifactsSender sends the ApplyArtifacts request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) ApplyArtifactsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// ApplyArtifactsResponder handles the response to the ApplyArtifacts request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) ApplyArtifactsResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateOrUpdateResource create or replace an existing Virtual Machine. This -// operation can take a while to complete. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual Machine. -func (client VirtualMachineClient) CreateOrUpdateResource(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, labName, name, labVirtualMachine, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "CreateOrUpdateResource", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "CreateOrUpdateResource", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "CreateOrUpdateResource", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client VirtualMachineClient) CreateOrUpdateResourcePreparer(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), - autorest.WithJSON(labVirtualMachine), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) CreateOrUpdateResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteResource delete virtual machine. This operation can take a while to -// complete. This method may poll for completion. Polling can be canceled by -// passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual Machine. -func (client VirtualMachineClient) DeleteResource(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, labName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "DeleteResource", nil, "Failure preparing request") - } - - resp, err := client.DeleteResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "DeleteResource", resp, "Failure sending request") - } - - result, err = client.DeleteResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "DeleteResource", resp, "Failure responding to request") - } - - return -} - -// DeleteResourcePreparer prepares the DeleteResource request. -func (client VirtualMachineClient) DeleteResourcePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// DeleteResourceSender sends the DeleteResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// DeleteResourceResponder handles the response to the DeleteResource request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetResource get virtual machine. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual Machine. -func (client VirtualMachineClient) GetResource(resourceGroupName string, labName string, name string) (result LabVirtualMachine, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "GetResource", nil, "Failure preparing request") - } - - resp, err := client.GetResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "GetResource", resp, "Failure sending request") - } - - result, err = client.GetResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "GetResource", resp, "Failure responding to request") - } - - return -} - -// GetResourcePreparer prepares the GetResource request. -func (client VirtualMachineClient) GetResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetResourceSender sends the GetResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) GetResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResourceResponder handles the response to the GetResource request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) GetResourceResponder(resp *http.Response) (result LabVirtualMachine, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list virtual machines in a given lab. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. filter is the filter to apply on the operation. top is the -// maximum number of resources to return from the operation. orderBy is the -// ordering expression for the results, using OData notation. -func (client VirtualMachineClient) List(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationLabVirtualMachine, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderBy) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "List", nil, "Failure preparing request") - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "List", resp, "Failure sending request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client VirtualMachineClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) ListResponder(resp *http.Response) (result ResponseWithContinuationLabVirtualMachine, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNextResults retrieves the next set of results, if any. -func (client VirtualMachineClient) ListNextResults(lastResults ResponseWithContinuationLabVirtualMachine) (result ResponseWithContinuationLabVirtualMachine, err error) { - req, err := lastResults.ResponseWithContinuationLabVirtualMachinePreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "List", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "List", resp, "Failure sending next results request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "List", resp, "Failure responding to next results request") - } - - return -} - -// PatchResource modify properties of virtual machines. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual Machine. -func (client VirtualMachineClient) PatchResource(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine) (result LabVirtualMachine, err error) { - req, err := client.PatchResourcePreparer(resourceGroupName, labName, name, labVirtualMachine) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "PatchResource", nil, "Failure preparing request") - } - - resp, err := client.PatchResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "PatchResource", resp, "Failure sending request") - } - - result, err = client.PatchResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "PatchResource", resp, "Failure responding to request") - } - - return -} - -// PatchResourcePreparer prepares the PatchResource request. -func (client VirtualMachineClient) PatchResourcePreparer(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), - autorest.WithJSON(labVirtualMachine), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// PatchResourceSender sends the PatchResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) PatchResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// PatchResourceResponder handles the response to the PatchResource request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) PatchResourceResponder(resp *http.Response) (result LabVirtualMachine, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Start start a Lab VM. This operation can take a while to complete. This -// method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual Machine. -func (client VirtualMachineClient) Start(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StartPreparer(resourceGroupName, labName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "Start", nil, "Failure preparing request") - } - - resp, err := client.StartSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "Start", resp, "Failure sending request") - } - - result, err = client.StartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "Start", resp, "Failure responding to request") - } - - return -} - -// StartPreparer prepares the Start request. -func (client VirtualMachineClient) StartPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// StartSender sends the Start request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) StartSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// StartResponder handles the response to the Start request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// Stop stop a Lab VM. This operation can take a while to complete. This -// method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual Machine. -func (client VirtualMachineClient) Stop(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.StopPreparer(resourceGroupName, labName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "Stop", nil, "Failure preparing request") - } - - resp, err := client.StopSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "Stop", resp, "Failure sending request") - } - - result, err = client.StopResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineClient", "Stop", resp, "Failure responding to request") - } - - return -} - -// StopPreparer prepares the Stop request. -func (client VirtualMachineClient) StopPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// StopSender sends the Stop request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualMachineClient) StopSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// StopResponder handles the response to the Stop request. The method always -// closes the http.Response Body. -func (client VirtualMachineClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} diff --git a/arm/devtestlabs/virtualmachines.go b/arm/devtestlabs/virtualmachines.go new file mode 100644 index 000000000000..bcd1f5194d15 --- /dev/null +++ b/arm/devtestlabs/virtualmachines.go @@ -0,0 +1,1045 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// VirtualMachinesClient is the the DevTest Labs Client. +type VirtualMachinesClient struct { + ManagementClient +} + +// NewVirtualMachinesClient creates an instance of the VirtualMachinesClient +// client. +func NewVirtualMachinesClient(subscriptionID string) VirtualMachinesClient { + return NewVirtualMachinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualMachinesClientWithBaseURI creates an instance of the +// VirtualMachinesClient client. +func NewVirtualMachinesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachinesClient { + return VirtualMachinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// AddDataDisk attach a new or existing data disk to virtual machine. This +// operation can take a while to complete. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. dataDiskProperties is +// request body for adding a new or existing data disk to a virtual machine. +func (client VirtualMachinesClient) AddDataDisk(resourceGroupName string, labName string, name string, dataDiskProperties DataDiskProperties, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.AddDataDiskPreparer(resourceGroupName, labName, name, dataDiskProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "AddDataDisk", nil, "Failure preparing request") + return + } + + resp, err := client.AddDataDiskSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "AddDataDisk", resp, "Failure sending request") + return + } + + result, err = client.AddDataDiskResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "AddDataDisk", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// AddDataDiskPreparer prepares the AddDataDisk request. +func (client VirtualMachinesClient) AddDataDiskPreparer(resourceGroupName string, labName string, name string, dataDiskProperties DataDiskProperties, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk", pathParameters), + autorest.WithJSON(dataDiskProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// AddDataDiskSender sends the AddDataDisk request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) AddDataDiskSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// AddDataDiskResponder handles the response to the AddDataDisk request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) AddDataDiskResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ApplyArtifacts apply artifacts to virtual machine. This operation can take a +// while to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. applyArtifactsRequest is +// request body for applying artifacts to a virtual machine. +func (client VirtualMachinesClient) ApplyArtifacts(resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ApplyArtifactsPreparer(resourceGroupName, labName, name, applyArtifactsRequest, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ApplyArtifacts", nil, "Failure preparing request") + return + } + + resp, err := client.ApplyArtifactsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ApplyArtifacts", resp, "Failure sending request") + return + } + + result, err = client.ApplyArtifactsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ApplyArtifacts", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ApplyArtifactsPreparer prepares the ApplyArtifacts request. +func (client VirtualMachinesClient) ApplyArtifactsPreparer(resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts", pathParameters), + autorest.WithJSON(applyArtifactsRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ApplyArtifactsSender sends the ApplyArtifacts request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) ApplyArtifactsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ApplyArtifactsResponder handles the response to the ApplyArtifacts request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) ApplyArtifactsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Claim take ownership of an existing virtual machine This operation can take +// a while to complete. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. +func (client VirtualMachinesClient) Claim(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ClaimPreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Claim", nil, "Failure preparing request") + return + } + + resp, err := client.ClaimSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Claim", resp, "Failure sending request") + return + } + + result, err = client.ClaimResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Claim", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ClaimPreparer prepares the Claim request. +func (client VirtualMachinesClient) ClaimPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ClaimSender sends the Claim request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) ClaimSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ClaimResponder handles the response to the Claim request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) ClaimResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate create or replace an existing Virtual machine. This operation +// can take a while to complete. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. labVirtualMachine is a +// virtual machine. +func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (<-chan LabVirtualMachine, <-chan error) { + resultChan := make(chan LabVirtualMachine, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: labVirtualMachine, + Constraints: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result LabVirtualMachine + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, labVirtualMachine, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VirtualMachinesClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), + autorest.WithJSON(labVirtualMachine), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) (result LabVirtualMachine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete virtual machine. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. +func (client VirtualMachinesClient) Delete(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client VirtualMachinesClient) DeletePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DetachDataDisk detach the specified disk from the virtual machine. This +// operation can take a while to complete. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. detachDataDiskProperties +// is request body for detaching data disk from a virtual machine. +func (client VirtualMachinesClient) DetachDataDisk(resourceGroupName string, labName string, name string, detachDataDiskProperties DetachDataDiskProperties, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DetachDataDiskPreparer(resourceGroupName, labName, name, detachDataDiskProperties, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "DetachDataDisk", nil, "Failure preparing request") + return + } + + resp, err := client.DetachDataDiskSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "DetachDataDisk", resp, "Failure sending request") + return + } + + result, err = client.DetachDataDiskResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "DetachDataDisk", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DetachDataDiskPreparer prepares the DetachDataDisk request. +func (client VirtualMachinesClient) DetachDataDiskPreparer(resourceGroupName string, labName string, name string, detachDataDiskProperties DetachDataDiskProperties, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk", pathParameters), + autorest.WithJSON(detachDataDiskProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DetachDataDiskSender sends the DetachDataDisk request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) DetachDataDiskSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DetachDataDiskResponder handles the response to the DetachDataDisk request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) DetachDataDiskResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get virtual machine. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. expand is specify the +// $expand query. Example: +// 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)' +func (client VirtualMachinesClient) Get(resourceGroupName string, labName string, name string, expand string) (result LabVirtualMachine, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualMachinesClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) GetResponder(resp *http.Response) (result LabVirtualMachine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list virtual machines in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. expand is specify the $expand query. Example: +// 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)' +// filter is the filter to apply to the operation. top is the maximum number of +// resources to return from the operation. orderby is the ordering expression +// for the results, using OData notation. +func (client VirtualMachinesClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLabVirtualMachine, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client VirtualMachinesClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationLabVirtualMachine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client VirtualMachinesClient) ListNextResults(lastResults ResponseWithContinuationLabVirtualMachine) (result ResponseWithContinuationLabVirtualMachine, err error) { + req, err := lastResults.ResponseWithContinuationLabVirtualMachinePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListApplicableSchedules lists all applicable schedules +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. +func (client VirtualMachinesClient) ListApplicableSchedules(resourceGroupName string, labName string, name string) (result ApplicableSchedule, err error) { + req, err := client.ListApplicableSchedulesPreparer(resourceGroupName, labName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ListApplicableSchedules", nil, "Failure preparing request") + return + } + + resp, err := client.ListApplicableSchedulesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ListApplicableSchedules", resp, "Failure sending request") + return + } + + result, err = client.ListApplicableSchedulesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ListApplicableSchedules", resp, "Failure responding to request") + } + + return +} + +// ListApplicableSchedulesPreparer prepares the ListApplicableSchedules request. +func (client VirtualMachinesClient) ListApplicableSchedulesPreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/listApplicableSchedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListApplicableSchedulesSender sends the ListApplicableSchedules request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) ListApplicableSchedulesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListApplicableSchedulesResponder handles the response to the ListApplicableSchedules request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) ListApplicableSchedulesResponder(resp *http.Response) (result ApplicableSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Start start a virtual machine. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. +func (client VirtualMachinesClient) Start(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// StartPreparer prepares the Start request. +func (client VirtualMachinesClient) StartPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) StartSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stop a virtual machine This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. +func (client VirtualMachinesClient) Stop(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.StopPreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Stop", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// StopPreparer prepares the Stop request. +func (client VirtualMachinesClient) StopPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update modify properties of virtual machines. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual machine. labVirtualMachine is a +// virtual machine. +func (client VirtualMachinesClient) Update(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachineFragment) (result LabVirtualMachine, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, name, labVirtualMachine) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualMachinesClient) UpdatePreparer(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachineFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters), + autorest.WithJSON(labVirtualMachine), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) UpdateResponder(resp *http.Response) (result LabVirtualMachine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/virtualmachineschedules.go b/arm/devtestlabs/virtualmachineschedules.go new file mode 100644 index 000000000000..509d9d03d61c --- /dev/null +++ b/arm/devtestlabs/virtualmachineschedules.go @@ -0,0 +1,523 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// VirtualMachineSchedulesClient is the the DevTest Labs Client. +type VirtualMachineSchedulesClient struct { + ManagementClient +} + +// NewVirtualMachineSchedulesClient creates an instance of the +// VirtualMachineSchedulesClient client. +func NewVirtualMachineSchedulesClient(subscriptionID string) VirtualMachineSchedulesClient { + return NewVirtualMachineSchedulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualMachineSchedulesClientWithBaseURI creates an instance of the +// VirtualMachineSchedulesClient client. +func NewVirtualMachineSchedulesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineSchedulesClient { + return VirtualMachineSchedulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing schedule. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. virtualMachineName is the name of the virtual machine. name is the +// name of the schedule. schedule is a schedule. +func (client VirtualMachineSchedulesClient) CreateOrUpdate(resourceGroupName string, labName string, virtualMachineName string, name string, schedule Schedule) (result Schedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: schedule, + Constraints: []validation.Constraint{{Target: "schedule.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "devtestlabs.VirtualMachineSchedulesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, virtualMachineName, name, schedule) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VirtualMachineSchedulesClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, virtualMachineName string, name string, schedule Schedule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineName": autorest.Encode("path", virtualMachineName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}", pathParameters), + autorest.WithJSON(schedule), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineSchedulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualMachineSchedulesClient) CreateOrUpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete schedule. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. virtualMachineName is the name of the virtual machine. name is the +// name of the schedule. +func (client VirtualMachineSchedulesClient) Delete(resourceGroupName string, labName string, virtualMachineName string, name string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, labName, virtualMachineName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VirtualMachineSchedulesClient) DeletePreparer(resourceGroupName string, labName string, virtualMachineName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineName": autorest.Encode("path", virtualMachineName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineSchedulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualMachineSchedulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Execute execute a schedule. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. virtualMachineName is the name of the virtual machine. name is the +// name of the schedule. +func (client VirtualMachineSchedulesClient) Execute(resourceGroupName string, labName string, virtualMachineName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ExecutePreparer(resourceGroupName, labName, virtualMachineName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Execute", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ExecutePreparer prepares the Execute request. +func (client VirtualMachineSchedulesClient) ExecutePreparer(resourceGroupName string, labName string, virtualMachineName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineName": autorest.Encode("path", virtualMachineName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}/execute", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineSchedulesClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client VirtualMachineSchedulesClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get schedule. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. virtualMachineName is the name of the virtual machine. name is the +// name of the schedule. expand is specify the $expand query. Example: +// 'properties($select=status)' +func (client VirtualMachineSchedulesClient) Get(resourceGroupName string, labName string, virtualMachineName string, name string, expand string) (result Schedule, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, virtualMachineName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualMachineSchedulesClient) GetPreparer(resourceGroupName string, labName string, virtualMachineName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineName": autorest.Encode("path", virtualMachineName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineSchedulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualMachineSchedulesClient) GetResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list schedules in a given virtual machine. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. virtualMachineName is the name of the virtual machine. expand is +// specify the $expand query. Example: 'properties($select=status)' filter is +// the filter to apply to the operation. top is the maximum number of resources +// to return from the operation. orderby is the ordering expression for the +// results, using OData notation. +func (client VirtualMachineSchedulesClient) List(resourceGroupName string, labName string, virtualMachineName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationSchedule, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, virtualMachineName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client VirtualMachineSchedulesClient) ListPreparer(resourceGroupName string, labName string, virtualMachineName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineName": autorest.Encode("path", virtualMachineName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineSchedulesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client VirtualMachineSchedulesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client VirtualMachineSchedulesClient) ListNextResults(lastResults ResponseWithContinuationSchedule) (result ResponseWithContinuationSchedule, err error) { + req, err := lastResults.ResponseWithContinuationSchedulePreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// Update modify properties of schedules. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. virtualMachineName is the name of the virtual machine. name is the +// name of the schedule. schedule is a schedule. +func (client VirtualMachineSchedulesClient) Update(resourceGroupName string, labName string, virtualMachineName string, name string, schedule ScheduleFragment) (result Schedule, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, virtualMachineName, name, schedule) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachineSchedulesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualMachineSchedulesClient) UpdatePreparer(resourceGroupName string, labName string, virtualMachineName string, name string, schedule ScheduleFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineName": autorest.Encode("path", virtualMachineName), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}", pathParameters), + autorest.WithJSON(schedule), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineSchedulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualMachineSchedulesClient) UpdateResponder(resp *http.Response) (result Schedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/devtestlabs/virtualnetworkoperations.go b/arm/devtestlabs/virtualnetworkoperations.go deleted file mode 100644 index 2e992f810ff8..000000000000 --- a/arm/devtestlabs/virtualnetworkoperations.go +++ /dev/null @@ -1,409 +0,0 @@ -package devtestlabs - -// Copyright (c) Microsoft and contributors. 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 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// VirtualNetworkOperationsClient is the azure DevTest Labs REST API. -type VirtualNetworkOperationsClient struct { - ManagementClient -} - -// NewVirtualNetworkOperationsClient creates an instance of the -// VirtualNetworkOperationsClient client. -func NewVirtualNetworkOperationsClient(subscriptionID string) VirtualNetworkOperationsClient { - return NewVirtualNetworkOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewVirtualNetworkOperationsClientWithBaseURI creates an instance of the -// VirtualNetworkOperationsClient client. -func NewVirtualNetworkOperationsClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkOperationsClient { - return VirtualNetworkOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdateResource create or replace an existing virtual network. This -// operation can take a while to complete. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual network. -func (client VirtualNetworkOperationsClient) CreateOrUpdateResource(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.CreateOrUpdateResourcePreparer(resourceGroupName, labName, name, virtualNetwork, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "CreateOrUpdateResource", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "CreateOrUpdateResource", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "CreateOrUpdateResource", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request. -func (client VirtualNetworkOperationsClient) CreateOrUpdateResourcePreparer(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), - autorest.WithJSON(virtualNetwork), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualNetworkOperationsClient) CreateOrUpdateResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always -// closes the http.Response Body. -func (client VirtualNetworkOperationsClient) CreateOrUpdateResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteResource delete virtual network. This operation can take a while to -// complete. This method may poll for completion. Polling can be canceled by -// passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual network. -func (client VirtualNetworkOperationsClient) DeleteResource(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeleteResourcePreparer(resourceGroupName, labName, name, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "DeleteResource", nil, "Failure preparing request") - } - - resp, err := client.DeleteResourceSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "DeleteResource", resp, "Failure sending request") - } - - result, err = client.DeleteResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "DeleteResource", resp, "Failure responding to request") - } - - return -} - -// DeleteResourcePreparer prepares the DeleteResource request. -func (client VirtualNetworkOperationsClient) DeleteResourcePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{Cancel: cancel}) -} - -// DeleteResourceSender sends the DeleteResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualNetworkOperationsClient) DeleteResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, - req, - azure.DoPollForAsynchronous(client.PollingDelay)) -} - -// DeleteResourceResponder handles the response to the DeleteResource request. The method always -// closes the http.Response Body. -func (client VirtualNetworkOperationsClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetResource get virtual network. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual network. -func (client VirtualNetworkOperationsClient) GetResource(resourceGroupName string, labName string, name string) (result VirtualNetwork, err error) { - req, err := client.GetResourcePreparer(resourceGroupName, labName, name) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "GetResource", nil, "Failure preparing request") - } - - resp, err := client.GetResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "GetResource", resp, "Failure sending request") - } - - result, err = client.GetResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "GetResource", resp, "Failure responding to request") - } - - return -} - -// GetResourcePreparer prepares the GetResource request. -func (client VirtualNetworkOperationsClient) GetResourcePreparer(resourceGroupName string, labName string, name string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// GetResourceSender sends the GetResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualNetworkOperationsClient) GetResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResourceResponder handles the response to the GetResource request. The method always -// closes the http.Response Body. -func (client VirtualNetworkOperationsClient) GetResourceResponder(resp *http.Response) (result VirtualNetwork, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list virtual networks in a given lab. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. filter is the filter to apply on the operation. top is the -// maximum number of resources to return from the operation. orderBy is the -// ordering expression for the results, using OData notation. -func (client VirtualNetworkOperationsClient) List(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationVirtualNetwork, err error) { - req, err := client.ListPreparer(resourceGroupName, labName, filter, top, orderBy) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "List", nil, "Failure preparing request") - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "List", resp, "Failure sending request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client VirtualNetworkOperationsClient) ListPreparer(resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = autorest.Encode("query", orderBy) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualNetworkOperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client VirtualNetworkOperationsClient) ListResponder(resp *http.Response) (result ResponseWithContinuationVirtualNetwork, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNextResults retrieves the next set of results, if any. -func (client VirtualNetworkOperationsClient) ListNextResults(lastResults ResponseWithContinuationVirtualNetwork) (result ResponseWithContinuationVirtualNetwork, err error) { - req, err := lastResults.ResponseWithContinuationVirtualNetworkPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "List", nil, "Failure preparing next results request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "List", resp, "Failure sending next results request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "List", resp, "Failure responding to next results request") - } - - return -} - -// PatchResource modify properties of virtual networks. -// -// resourceGroupName is the name of the resource group. labName is the name of -// the lab. name is the name of the virtual network. -func (client VirtualNetworkOperationsClient) PatchResource(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork) (result VirtualNetwork, err error) { - req, err := client.PatchResourcePreparer(resourceGroupName, labName, name, virtualNetwork) - if err != nil { - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "PatchResource", nil, "Failure preparing request") - } - - resp, err := client.PatchResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "PatchResource", resp, "Failure sending request") - } - - result, err = client.PatchResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworkOperationsClient", "PatchResource", resp, "Failure responding to request") - } - - return -} - -// PatchResourcePreparer prepares the PatchResource request. -func (client VirtualNetworkOperationsClient) PatchResourcePreparer(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "labName": autorest.Encode("path", labName), - "name": autorest.Encode("path", name), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), - autorest.WithJSON(virtualNetwork), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare(&http.Request{}) -} - -// PatchResourceSender sends the PatchResource request. The method will close the -// http.Response Body if it receives an error. -func (client VirtualNetworkOperationsClient) PatchResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// PatchResourceResponder handles the response to the PatchResource request. The method always -// closes the http.Response Body. -func (client VirtualNetworkOperationsClient) PatchResourceResponder(resp *http.Response) (result VirtualNetwork, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/arm/devtestlabs/virtualnetworks.go b/arm/devtestlabs/virtualnetworks.go new file mode 100644 index 000000000000..148411c28d6d --- /dev/null +++ b/arm/devtestlabs/virtualnetworks.go @@ -0,0 +1,457 @@ +package devtestlabs + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// VirtualNetworksClient is the the DevTest Labs Client. +type VirtualNetworksClient struct { + ManagementClient +} + +// NewVirtualNetworksClient creates an instance of the VirtualNetworksClient +// client. +func NewVirtualNetworksClient(subscriptionID string) VirtualNetworksClient { + return NewVirtualNetworksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualNetworksClientWithBaseURI creates an instance of the +// VirtualNetworksClient client. +func NewVirtualNetworksClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworksClient { + return VirtualNetworksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or replace an existing virtual network. This operation +// can take a while to complete. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual network. virtualNetwork is a +// virtual network. +func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork, cancel <-chan struct{}) (<-chan VirtualNetwork, <-chan error) { + resultChan := make(chan VirtualNetwork, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VirtualNetwork + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, virtualNetwork, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VirtualNetworksClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetwork, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), + autorest.WithJSON(virtualNetwork), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete virtual network. This operation can take a while to complete. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual network. +func (client VirtualNetworksClient) Delete(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, labName, name, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client VirtualNetworksClient) DeletePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualNetworksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get virtual network. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual network. expand is specify the +// $expand query. Example: 'properties($expand=externalSubnets)' +func (client VirtualNetworksClient) Get(resourceGroupName string, labName string, name string, expand string) (result VirtualNetwork, err error) { + req, err := client.GetPreparer(resourceGroupName, labName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualNetworksClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworksClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualNetworksClient) GetResponder(resp *http.Response) (result VirtualNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list virtual networks in a given lab. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. expand is specify the $expand query. Example: +// 'properties($expand=externalSubnets)' filter is the filter to apply to the +// operation. top is the maximum number of resources to return from the +// operation. orderby is the ordering expression for the results, using OData +// notation. +func (client VirtualNetworksClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationVirtualNetwork, err error) { + req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client VirtualNetworksClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworksClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client VirtualNetworksClient) ListResponder(resp *http.Response) (result ResponseWithContinuationVirtualNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client VirtualNetworksClient) ListNextResults(lastResults ResponseWithContinuationVirtualNetwork) (result ResponseWithContinuationVirtualNetwork, err error) { + req, err := lastResults.ResponseWithContinuationVirtualNetworkPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// Update modify properties of virtual networks. +// +// resourceGroupName is the name of the resource group. labName is the name of +// the lab. name is the name of the virtual network. virtualNetwork is a +// virtual network. +func (client VirtualNetworksClient) Update(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetworkFragment) (result VirtualNetwork, err error) { + req, err := client.UpdatePreparer(resourceGroupName, labName, name, virtualNetwork) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devtestlabs.VirtualNetworksClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualNetworksClient) UpdatePreparer(resourceGroupName string, labName string, name string, virtualNetwork VirtualNetworkFragment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "labName": autorest.Encode("path", labName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-05-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualnetworks/{name}", pathParameters), + autorest.WithJSON(virtualNetwork), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworksClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualNetworksClient) UpdateResponder(resp *http.Response) (result VirtualNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/disk/disks.go b/arm/disk/disks.go index 5653b185f5d8..4f7fce74fc48 100755 --- a/arm/disk/disks.go +++ b/arm/disk/disks.go @@ -48,7 +48,9 @@ func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClien // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. diskParameter is // disk object supplied in the body of the Put disk operation. -func (client DisksClient) CreateOrUpdate(resourceGroupName string, diskName string, diskParameter Model, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DisksClient) CreateOrUpdate(resourceGroupName string, diskName string, diskParameter Model, cancel <-chan struct{}) (<-chan Model, <-chan error) { + resultChan := make(chan Model, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: diskParameter, Constraints: []validation.Constraint{{Target: "diskParameter.Properties", Name: validation.Null, Rule: false, @@ -67,26 +69,40 @@ func (client DisksClient) CreateOrUpdate(resourceGroupName string, diskName stri }}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.DisksClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "disk.DisksClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Model + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -122,13 +138,14 @@ func (client DisksClient) CreateOrUpdateSender(req *http.Request) (*http.Respons // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result Model, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -138,24 +155,37 @@ func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result a // // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. -func (client DisksClient) Delete(resourceGroupName string, diskName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, diskName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure responding to request") - } - - return +func (client DisksClient) Delete(resourceGroupName string, diskName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, diskName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -189,13 +219,14 @@ func (client DisksClient) DeleteSender(req *http.Request) (*http.Response, error // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -206,13 +237,15 @@ func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest. func (client DisksClient) Get(resourceGroupName string, diskName string) (result Model, err error) { req, err := client.GetPreparer(resourceGroupName, diskName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -270,30 +303,46 @@ func (client DisksClient) GetResponder(resp *http.Response) (result Model, err e // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. grantAccessData // is access data object supplied in the body of the get disk access operation. -func (client DisksClient) GrantAccess(resourceGroupName string, diskName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DisksClient) GrantAccess(resourceGroupName string, diskName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (<-chan AccessURI, <-chan error) { + resultChan := make(chan AccessURI, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: grantAccessData, Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.DisksClient", "GrantAccess") - } - - req, err := client.GrantAccessPreparer(resourceGroupName, diskName, grantAccessData, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", nil, "Failure preparing request") - } - - resp, err := client.GrantAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure sending request") - } - - result, err = client.GrantAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "disk.DisksClient", "GrantAccess") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result AccessURI + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GrantAccessPreparer(resourceGroupName, diskName, grantAccessData, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", nil, "Failure preparing request") + return + } + + resp, err := client.GrantAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure sending request") + return + } + + result, err = client.GrantAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "GrantAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // GrantAccessPreparer prepares the GrantAccess request. @@ -329,13 +378,14 @@ func (client DisksClient) GrantAccessSender(req *http.Request) (*http.Response, // GrantAccessResponder handles the response to the GrantAccess request. The method always // closes the http.Response Body. -func (client DisksClient) GrantAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -343,13 +393,15 @@ func (client DisksClient) GrantAccessResponder(resp *http.Response) (result auto func (client DisksClient) List() (result ListType, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -428,13 +480,15 @@ func (client DisksClient) ListNextResults(lastResults ListType) (result ListType func (client DisksClient) ListByResourceGroup(resourceGroupName string) (result ListType, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.DisksClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -514,24 +568,37 @@ func (client DisksClient) ListByResourceGroupNextResults(lastResults ListType) ( // // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. -func (client DisksClient) RevokeAccess(resourceGroupName string, diskName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RevokeAccessPreparer(resourceGroupName, diskName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", nil, "Failure preparing request") - } - - resp, err := client.RevokeAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure sending request") - } - - result, err = client.RevokeAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure responding to request") - } - - return +func (client DisksClient) RevokeAccess(resourceGroupName string, diskName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RevokeAccessPreparer(resourceGroupName, diskName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", nil, "Failure preparing request") + return + } + + resp, err := client.RevokeAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure sending request") + return + } + + result, err = client.RevokeAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "RevokeAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RevokeAccessPreparer prepares the RevokeAccess request. @@ -565,13 +632,14 @@ func (client DisksClient) RevokeAccessSender(req *http.Request) (*http.Response, // RevokeAccessResponder handles the response to the RevokeAccess request. The method always // closes the http.Response Body. -func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -582,24 +650,37 @@ func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result aut // resourceGroupName is the name of the resource group. diskName is the name of // the disk within the given subscription and resource group. diskParameter is // disk object supplied in the body of the Patch disk operation. -func (client DisksClient) Update(resourceGroupName string, diskName string, diskParameter UpdateType, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.UpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Update", nil, "Failure preparing request") - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure sending request") - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure responding to request") - } - - return +func (client DisksClient) Update(resourceGroupName string, diskName string, diskParameter UpdateType, cancel <-chan struct{}) (<-chan Model, <-chan error) { + resultChan := make(chan Model, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Model + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, diskName, diskParameter, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.DisksClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -635,12 +716,13 @@ func (client DisksClient) UpdateSender(req *http.Request) (*http.Response, error // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client DisksClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DisksClient) UpdateResponder(resp *http.Response) (result Model, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/disk/snapshots.go b/arm/disk/snapshots.go index 55c51822a8cf..f4e5579d045e 100755 --- a/arm/disk/snapshots.go +++ b/arm/disk/snapshots.go @@ -49,7 +49,9 @@ func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) Snapsh // resourceGroupName is the name of the resource group. snapshotName is the // name of the snapshot within the given subscription and resource group. // snapshot is snapshot object supplied in the body of the Put disk operation. -func (client SnapshotsClient) CreateOrUpdate(resourceGroupName string, snapshotName string, snapshot Snapshot, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client SnapshotsClient) CreateOrUpdate(resourceGroupName string, snapshotName string, snapshot Snapshot, cancel <-chan struct{}) (<-chan Snapshot, <-chan error) { + resultChan := make(chan Snapshot, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: snapshot, Constraints: []validation.Constraint{{Target: "snapshot.Properties", Name: validation.Null, Rule: false, @@ -68,26 +70,40 @@ func (client SnapshotsClient) CreateOrUpdate(resourceGroupName string, snapshotN }}, }}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Snapshot + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -123,13 +139,14 @@ func (client SnapshotsClient) CreateOrUpdateSender(req *http.Request) (*http.Res // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result Snapshot, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -139,24 +156,37 @@ func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (resu // // resourceGroupName is the name of the resource group. snapshotName is the // name of the snapshot within the given subscription and resource group. -func (client SnapshotsClient) Delete(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, snapshotName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure responding to request") - } - - return +func (client SnapshotsClient) Delete(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, snapshotName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -190,13 +220,14 @@ func (client SnapshotsClient) DeleteSender(req *http.Request) (*http.Response, e // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -207,13 +238,15 @@ func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autor func (client SnapshotsClient) Get(resourceGroupName string, snapshotName string) (result Snapshot, err error) { req, err := client.GetPreparer(resourceGroupName, snapshotName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -273,30 +306,46 @@ func (client SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot // name of the snapshot within the given subscription and resource group. // grantAccessData is access data object supplied in the body of the get // snapshot access operation. -func (client SnapshotsClient) GrantAccess(resourceGroupName string, snapshotName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client SnapshotsClient) GrantAccess(resourceGroupName string, snapshotName string, grantAccessData GrantAccessData, cancel <-chan struct{}) (<-chan AccessURI, <-chan error) { + resultChan := make(chan AccessURI, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: grantAccessData, Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "GrantAccess") - } - - req, err := client.GrantAccessPreparer(resourceGroupName, snapshotName, grantAccessData, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", nil, "Failure preparing request") - } - - resp, err := client.GrantAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure sending request") - } - - result, err = client.GrantAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "disk.SnapshotsClient", "GrantAccess") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result AccessURI + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.GrantAccessPreparer(resourceGroupName, snapshotName, grantAccessData, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", nil, "Failure preparing request") + return + } + + resp, err := client.GrantAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure sending request") + return + } + + result, err = client.GrantAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "GrantAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // GrantAccessPreparer prepares the GrantAccess request. @@ -332,13 +381,14 @@ func (client SnapshotsClient) GrantAccessSender(req *http.Request) (*http.Respon // GrantAccessResponder handles the response to the GrantAccess request. The method always // closes the http.Response Body. -func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -346,13 +396,15 @@ func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result func (client SnapshotsClient) List() (result SnapshotList, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -431,13 +483,15 @@ func (client SnapshotsClient) ListNextResults(lastResults SnapshotList) (result func (client SnapshotsClient) ListByResourceGroup(resourceGroupName string) (result SnapshotList, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -518,24 +572,37 @@ func (client SnapshotsClient) ListByResourceGroupNextResults(lastResults Snapsho // // resourceGroupName is the name of the resource group. snapshotName is the // name of the snapshot within the given subscription and resource group. -func (client SnapshotsClient) RevokeAccess(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.RevokeAccessPreparer(resourceGroupName, snapshotName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request") - } - - resp, err := client.RevokeAccessSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure sending request") - } - - result, err = client.RevokeAccessResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure responding to request") - } - - return +func (client SnapshotsClient) RevokeAccess(resourceGroupName string, snapshotName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) { + resultChan := make(chan OperationStatusResponse, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result OperationStatusResponse + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RevokeAccessPreparer(resourceGroupName, snapshotName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request") + return + } + + resp, err := client.RevokeAccessSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure sending request") + return + } + + result, err = client.RevokeAccessResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "RevokeAccess", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RevokeAccessPreparer prepares the RevokeAccess request. @@ -569,13 +636,14 @@ func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (*http.Respo // RevokeAccessResponder handles the response to the RevokeAccess request. The method always // closes the http.Response Body. -func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result OperationStatusResponse, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -587,24 +655,37 @@ func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result // name of the snapshot within the given subscription and resource group. // snapshot is snapshot object supplied in the body of the Patch snapshot // operation. -func (client SnapshotsClient) Update(resourceGroupName string, snapshotName string, snapshot SnapshotUpdate, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.UpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", nil, "Failure preparing request") - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure sending request") - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure responding to request") - } - - return +func (client SnapshotsClient) Update(resourceGroupName string, snapshotName string, snapshot SnapshotUpdate, cancel <-chan struct{}) (<-chan Snapshot, <-chan error) { + resultChan := make(chan Snapshot, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Snapshot + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(resourceGroupName, snapshotName, snapshot, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "disk.SnapshotsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // UpdatePreparer prepares the Update request. @@ -640,12 +721,13 @@ func (client SnapshotsClient) UpdateSender(req *http.Request) (*http.Response, e // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result Snapshot, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } diff --git a/arm/disk/version.go b/arm/disk/version.go index 093c23a5437a..34af0258c8cf 100755 --- a/arm/disk/version.go +++ b/arm/disk/version.go @@ -20,10 +20,10 @@ package disk // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-disk/2016-04-30-preview" + return "Azure-SDK-For-Go/v10.0.0-beta arm-disk/2016-04-30-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/dns/recordsets.go b/arm/dns/recordsets.go index 240c42660c55..8d3992dd6672 100755 --- a/arm/dns/recordsets.go +++ b/arm/dns/recordsets.go @@ -56,13 +56,15 @@ func NewRecordSetsClientWithBaseURI(baseURI string, subscriptionID string) Recor func (client RecordSetsClient) CreateOrUpdate(resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, ifMatch string, ifNoneMatch string) (result RecordSet, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch, ifNoneMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -139,13 +141,15 @@ func (client RecordSetsClient) CreateOrUpdateResponder(resp *http.Response) (res func (client RecordSetsClient) Delete(resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, ifMatch string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, zoneName, relativeRecordSetName, recordType, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -210,13 +214,15 @@ func (client RecordSetsClient) DeleteResponder(resp *http.Response) (result auto func (client RecordSetsClient) Get(resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType) (result RecordSet, err error) { req, err := client.GetPreparer(resourceGroupName, zoneName, relativeRecordSetName, recordType) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -277,13 +283,15 @@ func (client RecordSetsClient) GetResponder(resp *http.Response) (result RecordS func (client RecordSetsClient) ListByDNSZone(resourceGroupName string, zoneName string, top *int32) (result RecordSetListResult, err error) { req, err := client.ListByDNSZonePreparer(resourceGroupName, zoneName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByDNSZone", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByDNSZone", nil, "Failure preparing request") + return } resp, err := client.ListByDNSZoneSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByDNSZone", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByDNSZone", resp, "Failure sending request") + return } result, err = client.ListByDNSZoneResponder(resp) @@ -370,13 +378,15 @@ func (client RecordSetsClient) ListByDNSZoneNextResults(lastResults RecordSetLis func (client RecordSetsClient) ListByType(resourceGroupName string, zoneName string, recordType RecordType, top *int32) (result RecordSetListResult, err error) { req, err := client.ListByTypePreparer(resourceGroupName, zoneName, recordType, top) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByType", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByType", nil, "Failure preparing request") + return } resp, err := client.ListByTypeSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByType", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListByType", resp, "Failure sending request") + return } result, err = client.ListByTypeResponder(resp) @@ -467,13 +477,15 @@ func (client RecordSetsClient) ListByTypeNextResults(lastResults RecordSetListRe func (client RecordSetsClient) Update(resourceGroupName string, zoneName string, relativeRecordSetName string, recordType RecordType, parameters RecordSet, ifMatch string) (result RecordSet, err error) { req, err := client.UpdatePreparer(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/dns/version.go b/arm/dns/version.go index 530508bf77e6..daa29c76de17 100755 --- a/arm/dns/version.go +++ b/arm/dns/version.go @@ -20,10 +20,10 @@ package dns // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-dns/2016-04-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-dns/2016-04-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/dns/zones.go b/arm/dns/zones.go index e421f8d9ce10..31ad0ba36f7b 100755 --- a/arm/dns/zones.go +++ b/arm/dns/zones.go @@ -52,13 +52,15 @@ func NewZonesClientWithBaseURI(baseURI string, subscriptionID string) ZonesClien func (client ZonesClient) CreateOrUpdate(resourceGroupName string, zoneName string, parameters Zone, ifMatch string, ifNoneMatch string) (result Zone, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, zoneName, parameters, ifMatch, ifNoneMatch) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -130,24 +132,37 @@ func (client ZonesClient) CreateOrUpdateResponder(resp *http.Response) (result Z // zone. Omit this value to always delete the current zone. Specify the // last-seen etag value to prevent accidentally deleting any concurrent // changes. -func (client ZonesClient) Delete(resourceGroupName string, zoneName string, ifMatch string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, zoneName, ifMatch, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", resp, "Failure responding to request") - } - - return +func (client ZonesClient) Delete(resourceGroupName string, zoneName string, ifMatch string, cancel <-chan struct{}) (<-chan ZoneDeleteResult, <-chan error) { + resultChan := make(chan ZoneDeleteResult, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ZoneDeleteResult + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, zoneName, ifMatch, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -185,13 +200,14 @@ func (client ZonesClient) DeleteSender(req *http.Request) (*http.Response, error // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client ZonesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ZonesClient) DeleteResponder(resp *http.Response) (result ZoneDeleteResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -203,13 +219,15 @@ func (client ZonesClient) DeleteResponder(resp *http.Response) (result autorest. func (client ZonesClient) Get(resourceGroupName string, zoneName string) (result Zone, err error) { req, err := client.GetPreparer(resourceGroupName, zoneName) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -267,13 +285,15 @@ func (client ZonesClient) GetResponder(resp *http.Response) (result Zone, err er func (client ZonesClient) List(top *int32) (result ZoneListResult, err error) { req, err := client.ListPreparer(top) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -357,13 +377,15 @@ func (client ZonesClient) ListNextResults(lastResults ZoneListResult) (result Zo func (client ZonesClient) ListByResourceGroup(resourceGroupName string, top *int32) (result ZoneListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "dns.ZonesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "dns.ZonesClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) diff --git a/arm/documentdb/databaseaccounts.go b/arm/documentdb/databaseaccounts.go index 86c62aa99af5..7d4480742267 100755 --- a/arm/documentdb/databaseaccounts.go +++ b/arm/documentdb/databaseaccounts.go @@ -58,13 +58,15 @@ func (client DatabaseAccountsClient) CheckNameExists(accountName string) (result req, err := client.CheckNameExistsPreparer(accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", nil, "Failure preparing request") + return } resp, err := client.CheckNameExistsSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure sending request") + return } result, err = client.CheckNameExistsResponder(resp) @@ -120,7 +122,9 @@ func (client DatabaseAccountsClient) CheckNameExistsResponder(resp *http.Respons // resourceGroupName is name of an Azure resource group. accountName is // documentDB database account name. createUpdateParameters is the parameters // to provide for the current database account. -func (client DatabaseAccountsClient) CreateOrUpdate(resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DatabaseAccountsClient) CreateOrUpdate(resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters, cancel <-chan struct{}) (<-chan DatabaseAccount, <-chan error) { + resultChan := make(chan DatabaseAccount, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -144,26 +148,40 @@ func (client DatabaseAccountsClient) CreateOrUpdate(resourceGroupName string, ac {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.DatabaseAccountOfferType", Name: validation.Null, Rule: true, Chain: nil}, }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, accountName, createUpdateParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result DatabaseAccount + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, accountName, createUpdateParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -199,13 +217,14 @@ func (client DatabaseAccountsClient) CreateOrUpdateSender(req *http.Request) (*h // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client DatabaseAccountsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DatabaseAccountsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseAccount, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -216,7 +235,9 @@ func (client DatabaseAccountsClient) CreateOrUpdateResponder(resp *http.Response // // resourceGroupName is name of an Azure resource group. accountName is // documentDB database account name. -func (client DatabaseAccountsClient) Delete(resourceGroupName string, accountName string, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DatabaseAccountsClient) Delete(resourceGroupName string, accountName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -225,26 +246,40 @@ func (client DatabaseAccountsClient) Delete(resourceGroupName string, accountNam {TargetValue: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "Delete") - } - - req, err := client.DeletePreparer(resourceGroupName, accountName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, accountName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -299,7 +334,9 @@ func (client DatabaseAccountsClient) DeleteResponder(resp *http.Response) (resul // resourceGroupName is name of an Azure resource group. accountName is // documentDB database account name. failoverParameters is the new failover // policies for the database account. -func (client DatabaseAccountsClient) FailoverPriorityChange(resourceGroupName string, accountName string, failoverParameters FailoverPolicies, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DatabaseAccountsClient) FailoverPriorityChange(resourceGroupName string, accountName string, failoverParameters FailoverPolicies, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -308,26 +345,40 @@ func (client DatabaseAccountsClient) FailoverPriorityChange(resourceGroupName st {TargetValue: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange") - } - - req, err := client.FailoverPriorityChangePreparer(resourceGroupName, accountName, failoverParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", nil, "Failure preparing request") - } - - resp, err := client.FailoverPriorityChangeSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", resp, "Failure sending request") - } - - result, err = client.FailoverPriorityChangeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.FailoverPriorityChangePreparer(resourceGroupName, accountName, failoverParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", nil, "Failure preparing request") + return + } + + resp, err := client.FailoverPriorityChangeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", resp, "Failure sending request") + return + } + + result, err = client.FailoverPriorityChangeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // FailoverPriorityChangePreparer prepares the FailoverPriorityChange request. @@ -392,13 +443,15 @@ func (client DatabaseAccountsClient) Get(resourceGroupName string, accountName s req, err := client.GetPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -454,13 +507,15 @@ func (client DatabaseAccountsClient) GetResponder(resp *http.Response) (result D func (client DatabaseAccountsClient) List() (result DatabaseAccountsListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -524,13 +579,15 @@ func (client DatabaseAccountsClient) ListByResourceGroup(resourceGroupName strin req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -599,13 +656,15 @@ func (client DatabaseAccountsClient) ListConnectionStrings(resourceGroupName str req, err := client.ListConnectionStringsPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", nil, "Failure preparing request") + return } resp, err := client.ListConnectionStringsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure sending request") + return } result, err = client.ListConnectionStringsResponder(resp) @@ -675,13 +734,15 @@ func (client DatabaseAccountsClient) ListKeys(resourceGroupName string, accountN req, err := client.ListKeysPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -751,13 +812,15 @@ func (client DatabaseAccountsClient) ListReadOnlyKeys(resourceGroupName string, req, err := client.ListReadOnlyKeysPreparer(resourceGroupName, accountName) if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", nil, "Failure preparing request") + return } resp, err := client.ListReadOnlyKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure sending request") + return } result, err = client.ListReadOnlyKeysResponder(resp) @@ -816,7 +879,9 @@ func (client DatabaseAccountsClient) ListReadOnlyKeysResponder(resp *http.Respon // resourceGroupName is name of an Azure resource group. accountName is // documentDB database account name. updateParameters is the tags parameter to // patch for the current database account. -func (client DatabaseAccountsClient) Patch(resourceGroupName string, accountName string, updateParameters DatabaseAccountPatchParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DatabaseAccountsClient) Patch(resourceGroupName string, accountName string, updateParameters DatabaseAccountPatchParameters, cancel <-chan struct{}) (<-chan DatabaseAccount, <-chan error) { + resultChan := make(chan DatabaseAccount, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -825,26 +890,40 @@ func (client DatabaseAccountsClient) Patch(resourceGroupName string, accountName {TargetValue: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "Patch") - } - - req, err := client.PatchPreparer(resourceGroupName, accountName, updateParameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", nil, "Failure preparing request") - } - - resp, err := client.PatchSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", resp, "Failure sending request") - } - - result, err = client.PatchResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "Patch") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result DatabaseAccount + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.PatchPreparer(resourceGroupName, accountName, updateParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", nil, "Failure preparing request") + return + } + + resp, err := client.PatchSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", resp, "Failure sending request") + return + } + + result, err = client.PatchResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // PatchPreparer prepares the Patch request. @@ -880,13 +959,14 @@ func (client DatabaseAccountsClient) PatchSender(req *http.Request) (*http.Respo // PatchResponder handles the response to the Patch request. The method always // closes the http.Response Body. -func (client DatabaseAccountsClient) PatchResponder(resp *http.Response) (result autorest.Response, err error) { +func (client DatabaseAccountsClient) PatchResponder(resp *http.Response) (result DatabaseAccount, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -898,7 +978,9 @@ func (client DatabaseAccountsClient) PatchResponder(resp *http.Response) (result // resourceGroupName is name of an Azure resource group. accountName is // documentDB database account name. keyToRegenerate is the name of the key to // regenerate. -func (client DatabaseAccountsClient) RegenerateKey(resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client DatabaseAccountsClient) RegenerateKey(resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -907,26 +989,40 @@ func (client DatabaseAccountsClient) RegenerateKey(resourceGroupName string, acc {TargetValue: accountName, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey") - } - - req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, keyToRegenerate, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", nil, "Failure preparing request") - } - - resp, err := client.RegenerateKeySender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", resp, "Failure sending request") - } - - result, err = client.RegenerateKeyResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, keyToRegenerate, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // RegenerateKeyPreparer prepares the RegenerateKey request. diff --git a/arm/documentdb/version.go b/arm/documentdb/version.go index ca6f793ce91e..f673442b10a2 100755 --- a/arm/documentdb/version.go +++ b/arm/documentdb/version.go @@ -20,10 +20,10 @@ package documentdb // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-documentdb/2015-04-08" + return "Azure-SDK-For-Go/v10.0.0-beta arm-documentdb/2015-04-08" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/eventhub/consumergroups.go b/arm/eventhub/consumergroups.go index 0ed63300f1fc..e9a194ba958e 100755 --- a/arm/eventhub/consumergroups.go +++ b/arm/eventhub/consumergroups.go @@ -43,13 +43,13 @@ func NewConsumerGroupsClientWithBaseURI(baseURI string, subscriptionID string) C } // CreateOrUpdate creates or updates an Event Hubs consumer group as a nested -// resource within a namespace. +// resource within a Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name consumerGroupName is the consumer group name parameters is -// parameters supplied to create a consumer group resource. -func (client ConsumerGroupsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string, parameters ConsumerGroup) (result ConsumerGroup, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name consumerGroupName is the consumer group name parameters is +// parameters supplied to create or update a consumer group resource. +func (client ConsumerGroupsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string, parameters ConsumerGroupCreateOrUpdateParameters) (result ConsumerGroupResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -62,19 +62,23 @@ func (client ConsumerGroupsClient) CreateOrUpdate(resourceGroupName string, name {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: consumerGroupName, Constraints: []validation.Constraint{{Target: "consumerGroupName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "consumerGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + {Target: "consumerGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate") } req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -86,7 +90,7 @@ func (client ConsumerGroupsClient) CreateOrUpdate(resourceGroupName string, name } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client ConsumerGroupsClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string, parameters ConsumerGroup) (*http.Request, error) { +func (client ConsumerGroupsClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string, parameters ConsumerGroupCreateOrUpdateParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ "consumerGroupName": autorest.Encode("path", consumerGroupName), "eventHubName": autorest.Encode("path", eventHubName), @@ -118,7 +122,7 @@ func (client ConsumerGroupsClient) CreateOrUpdateSender(req *http.Request) (*htt // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ConsumerGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ConsumerGroup, err error) { +func (client ConsumerGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ConsumerGroupResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -132,9 +136,9 @@ func (client ConsumerGroupsClient) CreateOrUpdateResponder(resp *http.Response) // Delete deletes a consumer group from the specified Event Hub and resource // group. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name consumerGroupName is the consumer group name +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name consumerGroupName is the consumer group name func (client ConsumerGroupsClient) Delete(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -154,13 +158,15 @@ func (client ConsumerGroupsClient) Delete(resourceGroupName string, namespaceNam req, err := client.DeletePreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -214,10 +220,10 @@ func (client ConsumerGroupsClient) DeleteResponder(resp *http.Response) (result // Get gets a description for the specified consumer group. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name consumerGroupName is the consumer group name -func (client ConsumerGroupsClient) Get(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (result ConsumerGroup, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name consumerGroupName is the consumer group name +func (client ConsumerGroupsClient) Get(resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (result ConsumerGroupResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -236,13 +242,15 @@ func (client ConsumerGroupsClient) Get(resourceGroupName string, namespaceName s req, err := client.GetPreparer(resourceGroupName, namespaceName, eventHubName, consumerGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -284,7 +292,7 @@ func (client ConsumerGroupsClient) GetSender(req *http.Request) (*http.Response, // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client ConsumerGroupsClient) GetResponder(resp *http.Response) (result ConsumerGroup, err error) { +func (client ConsumerGroupsClient) GetResponder(resp *http.Response) (result ConsumerGroupResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -295,13 +303,13 @@ func (client ConsumerGroupsClient) GetResponder(resp *http.Response) (result Con return } -// ListByEventHub gets all the consumer groups in a eventhub. An empty feed is -// returned if no consumer group exists in the eventhub. +// ListAll gets all the consumer groups in a Namespace. An empty feed is +// returned if no consumer group exists in the Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name -func (client ConsumerGroupsClient) ListByEventHub(resourceGroupName string, namespaceName string, eventHubName string) (result ConsumerGroupListResult, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name +func (client ConsumerGroupsClient) ListAll(resourceGroupName string, namespaceName string, eventHubName string) (result ConsumerGroupListResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -312,30 +320,32 @@ func (client ConsumerGroupsClient) ListByEventHub(resourceGroupName string, name {TargetValue: eventHubName, Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "ListByEventHub") + return result, validation.NewErrorWithValidationError(err, "eventhub.ConsumerGroupsClient", "ListAll") } - req, err := client.ListByEventHubPreparer(resourceGroupName, namespaceName, eventHubName) + req, err := client.ListAllPreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListByEventHub", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", nil, "Failure preparing request") + return } - resp, err := client.ListByEventHubSender(req) + resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListByEventHub", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure sending request") + return } - result, err = client.ListByEventHubResponder(resp) + result, err = client.ListAllResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListByEventHub", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure responding to request") } return } -// ListByEventHubPreparer prepares the ListByEventHub request. -func (client ConsumerGroupsClient) ListByEventHubPreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) { +// ListAllPreparer prepares the ListAll request. +func (client ConsumerGroupsClient) ListAllPreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "eventHubName": autorest.Encode("path", eventHubName), "namespaceName": autorest.Encode("path", namespaceName), @@ -356,15 +366,15 @@ func (client ConsumerGroupsClient) ListByEventHubPreparer(resourceGroupName stri return preparer.Prepare(&http.Request{}) } -// ListByEventHubSender sends the ListByEventHub request. The method will close the +// ListAllSender sends the ListAll request. The method will close the // http.Response Body if it receives an error. -func (client ConsumerGroupsClient) ListByEventHubSender(req *http.Request) (*http.Response, error) { +func (client ConsumerGroupsClient) ListAllSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByEventHubResponder handles the response to the ListByEventHub request. The method always +// ListAllResponder handles the response to the ListAll request. The method always // closes the http.Response Body. -func (client ConsumerGroupsClient) ListByEventHubResponder(resp *http.Response) (result ConsumerGroupListResult, err error) { +func (client ConsumerGroupsClient) ListAllResponder(resp *http.Response) (result ConsumerGroupListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -375,25 +385,25 @@ func (client ConsumerGroupsClient) ListByEventHubResponder(resp *http.Response) return } -// ListByEventHubNextResults retrieves the next set of results, if any. -func (client ConsumerGroupsClient) ListByEventHubNextResults(lastResults ConsumerGroupListResult) (result ConsumerGroupListResult, err error) { +// ListAllNextResults retrieves the next set of results, if any. +func (client ConsumerGroupsClient) ListAllNextResults(lastResults ConsumerGroupListResult) (result ConsumerGroupListResult, err error) { req, err := lastResults.ConsumerGroupListResultPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListByEventHub", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByEventHubSender(req) + resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListByEventHub", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure sending next results request") } - result, err = client.ListByEventHubResponder(resp) + result, err = client.ListAllResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListByEventHub", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "eventhub.ConsumerGroupsClient", "ListAll", resp, "Failure responding to next results request") } return diff --git a/arm/eventhub/eventhubs.go b/arm/eventhub/eventhubs.go index ac65a07656fd..359e0da10cd2 100755 --- a/arm/eventhub/eventhubs.go +++ b/arm/eventhub/eventhubs.go @@ -42,13 +42,12 @@ func NewEventHubsClientWithBaseURI(baseURI string, subscriptionID string) EventH } // CreateOrUpdate creates or updates a new Event Hub as a nested resource -// within a namespace. +// within a Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name parameters is parameters supplied to create an Event Hub -// resource. -func (client EventHubsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, parameters EventHub) (result EventHub, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name parameters is parameters supplied to create an Event Hub resource. +func (client EventHubsClient) CreateOrUpdate(resourceGroupName string, namespaceName string, eventHubName string, parameters CreateOrUpdateParameters) (result ResourceType, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -58,19 +57,23 @@ func (client EventHubsClient) CreateOrUpdate(resourceGroupName string, namespace {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, {TargetValue: eventHubName, Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "CreateOrUpdate") } req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, eventHubName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -82,7 +85,7 @@ func (client EventHubsClient) CreateOrUpdate(resourceGroupName string, namespace } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client EventHubsClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, eventHubName string, parameters EventHub) (*http.Request, error) { +func (client EventHubsClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, eventHubName string, parameters CreateOrUpdateParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ "eventHubName": autorest.Encode("path", eventHubName), "namespaceName": autorest.Encode("path", namespaceName), @@ -113,7 +116,7 @@ func (client EventHubsClient) CreateOrUpdateSender(req *http.Request) (*http.Res // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client EventHubsClient) CreateOrUpdateResponder(resp *http.Response) (result EventHub, err error) { +func (client EventHubsClient) CreateOrUpdateResponder(resp *http.Response) (result ResourceType, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -124,14 +127,14 @@ func (client EventHubsClient) CreateOrUpdateResponder(resp *http.Response) (resu return } -// CreateOrUpdateAuthorizationRule creates or updates an authorization rule for +// CreateOrUpdateAuthorizationRule creates or updates an AuthorizationRule for // the specified Event Hub. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name authorizationRuleName is the authorizationrule name. -// parameters is the shared access authorization rule. -func (client EventHubsClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRule) (result SharedAccessAuthorizationRule, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. parameters is +// the shared access AuthorizationRule. +func (client EventHubsClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -153,13 +156,15 @@ func (client EventHubsClient) CreateOrUpdateAuthorizationRule(resourceGroupName req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) @@ -171,7 +176,7 @@ func (client EventHubsClient) CreateOrUpdateAuthorizationRule(resourceGroupName } // CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request. -func (client EventHubsClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRule) (*http.Request, error) { +func (client EventHubsClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationRuleName": autorest.Encode("path", authorizationRuleName), "eventHubName": autorest.Encode("path", eventHubName), @@ -203,7 +208,7 @@ func (client EventHubsClient) CreateOrUpdateAuthorizationRuleSender(req *http.Re // CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always // closes the http.Response Body. -func (client EventHubsClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRule, err error) { +func (client EventHubsClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -214,11 +219,11 @@ func (client EventHubsClient) CreateOrUpdateAuthorizationRuleResponder(resp *htt return } -// Delete deletes an Event Hub from the specified namespace and resource group. +// Delete deletes an Event Hub from the specified Namespace and resource group. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name func (client EventHubsClient) Delete(resourceGroupName string, namespaceName string, eventHubName string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -235,13 +240,15 @@ func (client EventHubsClient) Delete(resourceGroupName string, namespaceName str req, err := client.DeletePreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -292,11 +299,11 @@ func (client EventHubsClient) DeleteResponder(resp *http.Response) (result autor return } -// DeleteAuthorizationRule deletes an Event Hubs authorization rule. +// DeleteAuthorizationRule deletes an Event Hub AuthorizationRule. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name authorizationRuleName is the authorizationrule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. func (client EventHubsClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -316,13 +323,15 @@ func (client EventHubsClient) DeleteAuthorizationRule(resourceGroupName string, req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.DeleteAuthorizationRuleSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "DeleteAuthorizationRule", resp, "Failure sending request") + return } result, err = client.DeleteAuthorizationRuleResponder(resp) @@ -376,10 +385,10 @@ func (client EventHubsClient) DeleteAuthorizationRuleResponder(resp *http.Respon // Get gets an Event Hubs description for the specified Event Hub. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name -func (client EventHubsClient) Get(resourceGroupName string, namespaceName string, eventHubName string) (result EventHub, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name +func (client EventHubsClient) Get(resourceGroupName string, namespaceName string, eventHubName string) (result ResourceType, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -395,13 +404,15 @@ func (client EventHubsClient) Get(resourceGroupName string, namespaceName string req, err := client.GetPreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -442,7 +453,7 @@ func (client EventHubsClient) GetSender(req *http.Request) (*http.Response, erro // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client EventHubsClient) GetResponder(resp *http.Response) (result EventHub, err error) { +func (client EventHubsClient) GetResponder(resp *http.Response) (result ResourceType, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -453,13 +464,13 @@ func (client EventHubsClient) GetResponder(resp *http.Response) (result EventHub return } -// GetAuthorizationRule gets an authorization rule for an Event Hub by rule +// GetAuthorizationRule gets an AuthorizationRule for an Event Hub by rule // name. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name authorizationRuleName is the authorizationrule name. -func (client EventHubsClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result SharedAccessAuthorizationRule, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. +func (client EventHubsClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -478,13 +489,15 @@ func (client EventHubsClient) GetAuthorizationRule(resourceGroupName string, nam req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.GetAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "GetAuthorizationRule", resp, "Failure sending request") + return } result, err = client.GetAuthorizationRuleResponder(resp) @@ -526,7 +539,7 @@ func (client EventHubsClient) GetAuthorizationRuleSender(req *http.Request) (*ht // GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always // closes the http.Response Body. -func (client EventHubsClient) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRule, err error) { +func (client EventHubsClient) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -537,48 +550,45 @@ func (client EventHubsClient) GetAuthorizationRuleResponder(resp *http.Response) return } -// ListAuthorizationRules gets the authorization rules for an Event Hub. +// ListAll gets all the Event Hubs in a Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name -func (client EventHubsClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, eventHubName string) (result SharedAccessAuthorizationRuleListResult, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name +func (client EventHubsClient) ListAll(resourceGroupName string, namespaceName string) (result ListResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: namespaceName, Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: eventHubName, - Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "ListAuthorizationRules") + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "ListAll") } - req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName, eventHubName) + req, err := client.ListAllPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", nil, "Failure preparing request") + return } - resp, err := client.ListAuthorizationRulesSender(req) + resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure sending request") + return } - result, err = client.ListAuthorizationRulesResponder(resp) + result, err = client.ListAllResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure responding to request") } return } -// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. -func (client EventHubsClient) ListAuthorizationRulesPreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) { +// ListAllPreparer prepares the ListAll request. +func (client EventHubsClient) ListAllPreparer(resourceGroupName string, namespaceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "eventHubName": autorest.Encode("path", eventHubName), "namespaceName": autorest.Encode("path", namespaceName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), @@ -592,20 +602,20 @@ func (client EventHubsClient) ListAuthorizationRulesPreparer(resourceGroupName s preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the +// ListAllSender sends the ListAll request. The method will close the // http.Response Body if it receives an error. -func (client EventHubsClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { +func (client EventHubsClient) ListAllSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always +// ListAllResponder handles the response to the ListAll request. The method always // closes the http.Response Body. -func (client EventHubsClient) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) { +func (client EventHubsClient) ListAllResponder(resp *http.Response) (result ListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -616,67 +626,74 @@ func (client EventHubsClient) ListAuthorizationRulesResponder(resp *http.Respons return } -// ListAuthorizationRulesNextResults retrieves the next set of results, if any. -func (client EventHubsClient) ListAuthorizationRulesNextResults(lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) { - req, err := lastResults.SharedAccessAuthorizationRuleListResultPreparer() +// ListAllNextResults retrieves the next set of results, if any. +func (client EventHubsClient) ListAllNextResults(lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.ListResultPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListAuthorizationRulesSender(req) + resp, err := client.ListAllSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure sending next results request") } - result, err = client.ListAuthorizationRulesResponder(resp) + result, err = client.ListAllResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAll", resp, "Failure responding to next results request") } return } -// ListByNamespace gets all the Event Hubs in a namespace. +// ListAuthorizationRules gets the authorization rules for an Event Hub. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name -func (client EventHubsClient) ListByNamespace(resourceGroupName string, namespaceName string) (result ListResult, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name +func (client EventHubsClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, eventHubName string) (result SharedAccessAuthorizationRuleListResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: namespaceName, Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "ListByNamespace") + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: eventHubName, + Constraints: []validation.Constraint{{Target: "eventHubName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "eventHubName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.EventHubsClient", "ListAuthorizationRules") } - req, err := client.ListByNamespacePreparer(resourceGroupName, namespaceName) + req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName, eventHubName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListByNamespace", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing request") + return } - resp, err := client.ListByNamespaceSender(req) + resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListByNamespace", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending request") + return } - result, err = client.ListByNamespaceResponder(resp) + result, err = client.ListAuthorizationRulesResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListByNamespace", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure responding to request") } return } -// ListByNamespacePreparer prepares the ListByNamespace request. -func (client EventHubsClient) ListByNamespacePreparer(resourceGroupName string, namespaceName string) (*http.Request, error) { +// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. +func (client EventHubsClient) ListAuthorizationRulesPreparer(resourceGroupName string, namespaceName string, eventHubName string) (*http.Request, error) { pathParameters := map[string]interface{}{ + "eventHubName": autorest.Encode("path", eventHubName), "namespaceName": autorest.Encode("path", namespaceName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), @@ -690,20 +707,20 @@ func (client EventHubsClient) ListByNamespacePreparer(resourceGroupName string, preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/eventhubs/{eventHubName}/authorizationRules", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListByNamespaceSender sends the ListByNamespace request. The method will close the +// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the // http.Response Body if it receives an error. -func (client EventHubsClient) ListByNamespaceSender(req *http.Request) (*http.Response, error) { +func (client EventHubsClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByNamespaceResponder handles the response to the ListByNamespace request. The method always +// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always // closes the http.Response Body. -func (client EventHubsClient) ListByNamespaceResponder(resp *http.Response) (result ListResult, err error) { +func (client EventHubsClient) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -714,25 +731,25 @@ func (client EventHubsClient) ListByNamespaceResponder(resp *http.Response) (res return } -// ListByNamespaceNextResults retrieves the next set of results, if any. -func (client EventHubsClient) ListByNamespaceNextResults(lastResults ListResult) (result ListResult, err error) { - req, err := lastResults.ListResultPreparer() +// ListAuthorizationRulesNextResults retrieves the next set of results, if any. +func (client EventHubsClient) ListAuthorizationRulesNextResults(lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) { + req, err := lastResults.SharedAccessAuthorizationRuleListResultPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListByNamespace", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByNamespaceSender(req) + resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListByNamespace", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure sending next results request") } - result, err = client.ListByNamespaceResponder(resp) + result, err = client.ListAuthorizationRulesResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListByNamespace", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListAuthorizationRules", resp, "Failure responding to next results request") } return @@ -740,9 +757,9 @@ func (client EventHubsClient) ListByNamespaceNextResults(lastResults ListResult) // ListKeys gets the ACS and SAS connection strings for the Event Hub. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name authorizationRuleName is the authorizationrule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. func (client EventHubsClient) ListKeys(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string) (result ResourceListKeys, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -762,13 +779,15 @@ func (client EventHubsClient) ListKeys(resourceGroupName string, namespaceName s req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -824,10 +843,11 @@ func (client EventHubsClient) ListKeysResponder(resp *http.Response) (result Res // RegenerateKeys regenerates the ACS and SAS connection strings for the Event // Hub. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name eventHubName is the -// eventhub name authorizationRuleName is the authorizationrule name. -// parameters is parameters supplied to regenerate the authorization rule. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name eventHubName is the Event +// Hub name authorizationRuleName is the authorization rule name. parameters is +// parameters supplied to regenerate the AuthorizationRule Keys +// (PrimaryKey/SecondaryKey). func (client EventHubsClient) RegenerateKeys(resourceGroupName string, namespaceName string, eventHubName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -847,13 +867,15 @@ func (client EventHubsClient) RegenerateKeys(resourceGroupName string, namespace req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, eventHubName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.EventHubsClient", "RegenerateKeys", resp, "Failure sending request") + return } result, err = client.RegenerateKeysResponder(resp) diff --git a/arm/eventhub/models.go b/arm/eventhub/models.go index 07fc20a04097..08d197ada978 100755 --- a/arm/eventhub/models.go +++ b/arm/eventhub/models.go @@ -61,6 +61,51 @@ const ( Unknown EntityStatus = "Unknown" ) +// NamespaceState enumerates the values for namespace state. +type NamespaceState string + +const ( + // NamespaceStateActivating specifies the namespace state activating state + // for namespace state. + NamespaceStateActivating NamespaceState = "Activating" + // NamespaceStateActive specifies the namespace state active state for + // namespace state. + NamespaceStateActive NamespaceState = "Active" + // NamespaceStateCreated specifies the namespace state created state for + // namespace state. + NamespaceStateCreated NamespaceState = "Created" + // NamespaceStateCreating specifies the namespace state creating state for + // namespace state. + NamespaceStateCreating NamespaceState = "Creating" + // NamespaceStateDisabled specifies the namespace state disabled state for + // namespace state. + NamespaceStateDisabled NamespaceState = "Disabled" + // NamespaceStateDisabling specifies the namespace state disabling state + // for namespace state. + NamespaceStateDisabling NamespaceState = "Disabling" + // NamespaceStateEnabling specifies the namespace state enabling state for + // namespace state. + NamespaceStateEnabling NamespaceState = "Enabling" + // NamespaceStateFailed specifies the namespace state failed state for + // namespace state. + NamespaceStateFailed NamespaceState = "Failed" + // NamespaceStateRemoved specifies the namespace state removed state for + // namespace state. + NamespaceStateRemoved NamespaceState = "Removed" + // NamespaceStateRemoving specifies the namespace state removing state for + // namespace state. + NamespaceStateRemoving NamespaceState = "Removing" + // NamespaceStateSoftDeleted specifies the namespace state soft deleted + // state for namespace state. + NamespaceStateSoftDeleted NamespaceState = "SoftDeleted" + // NamespaceStateSoftDeleting specifies the namespace state soft deleting + // state for namespace state. + NamespaceStateSoftDeleting NamespaceState = "SoftDeleting" + // NamespaceStateUnknown specifies the namespace state unknown state for + // namespace state. + NamespaceStateUnknown NamespaceState = "Unknown" +) + // Policykey enumerates the values for policykey. type Policykey string @@ -114,14 +159,14 @@ const ( TooManyNamespaceInCurrentSubscription UnavailableReason = "TooManyNamespaceInCurrentSubscription" ) -// CheckNameAvailability is description of a Check Name availability request -// properties. -type CheckNameAvailability struct { +// CheckNameAvailabilityParameter is parameter supplied to check Namespace name +// availability operation +type CheckNameAvailabilityParameter struct { Name *string `json:"name,omitempty"` } -// CheckNameAvailabilityResult is description of a Check Name availability -// request properties. +// CheckNameAvailabilityResult is the Result of the CheckNameAvailability +// operation type CheckNameAvailabilityResult struct { autorest.Response `json:"-"` NameAvailable *bool `json:"nameAvailable,omitempty"` @@ -129,21 +174,20 @@ type CheckNameAvailabilityResult struct { Message *string `json:"message,omitempty"` } -// ConsumerGroup is description of the consumer group resource. -type ConsumerGroup struct { - autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` +// ConsumerGroupCreateOrUpdateParameters is parameters supplied to the Create +// Or Update Consumer Group operation. +type ConsumerGroupCreateOrUpdateParameters struct { + Location *string `json:"location,omitempty"` Type *string `json:"type,omitempty"` + Name *string `json:"name,omitempty"` *ConsumerGroupProperties `json:"properties,omitempty"` } -// ConsumerGroupListResult is the response to the List Consumer Group -// operation. +// ConsumerGroupListResult is the result to the List Consumer Group operation. type ConsumerGroupListResult struct { autorest.Response `json:"-"` - Value *[]ConsumerGroup `json:"value,omitempty"` - NextLink *string `json:"nextLink,omitempty"` + Value *[]ConsumerGroupResource `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // ConsumerGroupListResultPreparer prepares a request to retrieve the next set of results. It returns @@ -158,7 +202,8 @@ func (client ConsumerGroupListResult) ConsumerGroupListResultPreparer() (*http.R autorest.WithBaseURL(to.String(client.NextLink))) } -// ConsumerGroupProperties is description of a Consumer Group properties. +// ConsumerGroupProperties is properties supplied to the Create Or Update +// Consumer Group operation. type ConsumerGroupProperties struct { CreatedAt *date.Time `json:"createdAt,omitempty"` EventHubPath *string `json:"eventHubPath,omitempty"` @@ -166,27 +211,29 @@ type ConsumerGroupProperties struct { UserMetadata *string `json:"userMetadata,omitempty"` } -// ErrorResponse is error reponse indicates EventHub service is not able to -// process the incoming request. The reason is provided in the error message. -type ErrorResponse struct { - Code *string `json:"code,omitempty"` - Message *string `json:"message,omitempty"` +// ConsumerGroupResource is single item in List or Get Consumer group operation +type ConsumerGroupResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *ConsumerGroupProperties `json:"properties,omitempty"` } -// EventHub is description of the Event Hub resource. -type EventHub struct { - autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` - *Properties `json:"properties,omitempty"` +// CreateOrUpdateParameters is parameters supplied to the Create Or Update +// Event Hub operation. +type CreateOrUpdateParameters struct { + Location *string `json:"location,omitempty"` + Type *string `json:"type,omitempty"` + Name *string `json:"name,omitempty"` + *Properties `json:"properties,omitempty"` } -// ListResult is the response of the List Event Hubs operation. +// ListResult is the result of the List EventHubs operation. type ListResult struct { autorest.Response `json:"-"` - Value *[]EventHub `json:"value,omitempty"` - NextLink *string `json:"nextLink,omitempty"` + Value *[]ResourceType `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // ListResultPreparer prepares a request to retrieve the next set of results. It returns @@ -201,23 +248,20 @@ func (client ListResult) ListResultPreparer() (*http.Request, error) { autorest.WithBaseURL(to.String(client.NextLink))) } -// Namespace is description of a namespace resource. -type Namespace struct { - autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` +// NamespaceCreateOrUpdateParameters is parameters supplied to the Create Or +// Update Namespace operation. +type NamespaceCreateOrUpdateParameters struct { Location *string `json:"location,omitempty"` - Tags *map[string]*string `json:"tags,omitempty"` Sku *Sku `json:"sku,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` *NamespaceProperties `json:"properties,omitempty"` } // NamespaceListResult is the response of the List Namespace operation. type NamespaceListResult struct { autorest.Response `json:"-"` - Value *[]Namespace `json:"value,omitempty"` - NextLink *string `json:"nextLink,omitempty"` + Value *[]NamespaceResource `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // NamespaceListResultPreparer prepares a request to retrieve the next set of results. It returns @@ -232,22 +276,38 @@ func (client NamespaceListResult) NamespaceListResultPreparer() (*http.Request, autorest.WithBaseURL(to.String(client.NextLink))) } -// NamespaceProperties is properties of the namespace. +// NamespaceProperties is properties of the Namespace supplied for create or +// update Namespace operation type NamespaceProperties struct { - ProvisioningState *string `json:"provisioningState,omitempty"` - CreatedAt *date.Time `json:"createdAt,omitempty"` - UpdatedAt *date.Time `json:"updatedAt,omitempty"` - ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` + Status NamespaceState `json:"status,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + CreatedAt *date.Time `json:"createdAt,omitempty"` + UpdatedAt *date.Time `json:"updatedAt,omitempty"` + ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` + MetricID *string `json:"metricId,omitempty"` + Enabled *bool `json:"enabled,omitempty"` } -// NamespaceUpdateParameter is parameters supplied to the Patch Namespace -// operation. +// NamespaceResource is single Namespace item in List or Get Operation +type NamespaceResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Sku *Sku `json:"sku,omitempty"` + *NamespaceProperties `json:"properties,omitempty"` +} + +// NamespaceUpdateParameter is parameters supplied to the Patch/update +// Namespace operation. type NamespaceUpdateParameter struct { Tags *map[string]*string `json:"tags,omitempty"` Sku *Sku `json:"sku,omitempty"` } -// Operation is a EventHub REST API operation +// Operation is a Event Hub REST API operation type Operation struct { Name *string `json:"name,omitempty"` Display *OperationDisplay `json:"display,omitempty"` @@ -260,8 +320,9 @@ type OperationDisplay struct { Operation *string `json:"operation,omitempty"` } -// OperationListResult is result of the request to list EventHub operations. It -// contains a list of operations and a URL link to get the next set of results. +// OperationListResult is result of the request to list Event Hub operations. +// It contains a list of operations and a URL link to get the next set of +// results. type OperationListResult struct { autorest.Response `json:"-"` Value *[]Operation `json:"value,omitempty"` @@ -280,7 +341,8 @@ func (client OperationListResult) OperationListResultPreparer() (*http.Request, autorest.WithBaseURL(to.String(client.NextLink))) } -// Properties is description of a EventHub Properties. +// Properties is properties supplied to the Create Or Update Event Hub +// operation. type Properties struct { CreatedAt *date.Time `json:"createdAt,omitempty"` MessageRetentionInDays *int64 `json:"messageRetentionInDays,omitempty"` @@ -291,7 +353,7 @@ type Properties struct { } // RegenerateKeysParameters is parameters supplied to the Regenerate -// Authorization Rule operation. +// Authorization Rule keys operation. type RegenerateKeysParameters struct { Policykey Policykey `json:"policykey,omitempty"` } @@ -313,13 +375,20 @@ type ResourceListKeys struct { KeyName *string `json:"keyName,omitempty"` } -// SharedAccessAuthorizationRule is description of a namespace authorization -// rule. -type SharedAccessAuthorizationRule struct { - autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` +// ResourceType is single item in List or Get Event Hub operation +type ResourceType struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *Properties `json:"properties,omitempty"` +} + +// SharedAccessAuthorizationRuleCreateOrUpdateParameters is parameters supplied +// to the Create Or Update Authorization Rules operation. +type SharedAccessAuthorizationRuleCreateOrUpdateParameters struct { + Location *string `json:"location,omitempty"` Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` } @@ -327,8 +396,8 @@ type SharedAccessAuthorizationRule struct { // Namespace operation. type SharedAccessAuthorizationRuleListResult struct { autorest.Response `json:"-"` - Value *[]SharedAccessAuthorizationRule `json:"value,omitempty"` - NextLink *string `json:"nextLink,omitempty"` + Value *[]SharedAccessAuthorizationRuleResource `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // SharedAccessAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. It returns @@ -343,13 +412,23 @@ func (client SharedAccessAuthorizationRuleListResult) SharedAccessAuthorizationR autorest.WithBaseURL(to.String(client.NextLink))) } -// SharedAccessAuthorizationRuleProperties is sharedAccessAuthorizationRule -// properties. +// SharedAccessAuthorizationRuleProperties is properties supplied to create or +// update SharedAccessAuthorizationRule type SharedAccessAuthorizationRuleProperties struct { Rights *[]AccessRights `json:"rights,omitempty"` } -// Sku is sKU of the namespace. +// SharedAccessAuthorizationRuleResource is single item in a List or Get +// AuthorizationRule operation +type SharedAccessAuthorizationRuleResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` +} + +// Sku is sKU parameters supplied to the create Namespace operation type Sku struct { Name SkuName `json:"name,omitempty"` Tier SkuTier `json:"tier,omitempty"` diff --git a/arm/eventhub/namespaces.go b/arm/eventhub/namespaces.go index f9315bc9aae5..2f1f3bcbb252 100755 --- a/arm/eventhub/namespaces.go +++ b/arm/eventhub/namespaces.go @@ -41,37 +41,39 @@ func NewNamespacesClientWithBaseURI(baseURI string, subscriptionID string) Names return NamespacesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CheckNameAvailabilityMethod check the give namespace name availability. +// CheckNameAvailability check the give Namespace name availability. // -// parameters is parameters to check availability of the given namespace name -func (client NamespacesClient) CheckNameAvailabilityMethod(parameters CheckNameAvailability) (result CheckNameAvailabilityResult, err error) { +// parameters is parameters to check availability of the given Namespace name +func (client NamespacesClient) CheckNameAvailability(parameters CheckNameAvailabilityParameter) (result CheckNameAvailabilityResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CheckNameAvailabilityMethod") + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CheckNameAvailability") } - req, err := client.CheckNameAvailabilityMethodPreparer(parameters) + req, err := client.CheckNameAvailabilityPreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailabilityMethod", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailability", nil, "Failure preparing request") + return } - resp, err := client.CheckNameAvailabilityMethodSender(req) + resp, err := client.CheckNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailabilityMethod", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailability", resp, "Failure sending request") + return } - result, err = client.CheckNameAvailabilityMethodResponder(resp) + result, err = client.CheckNameAvailabilityResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailabilityMethod", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CheckNameAvailability", resp, "Failure responding to request") } return } -// CheckNameAvailabilityMethodPreparer prepares the CheckNameAvailabilityMethod request. -func (client NamespacesClient) CheckNameAvailabilityMethodPreparer(parameters CheckNameAvailability) (*http.Request, error) { +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client NamespacesClient) CheckNameAvailabilityPreparer(parameters CheckNameAvailabilityParameter) (*http.Request, error) { pathParameters := map[string]interface{}{ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -91,15 +93,15 @@ func (client NamespacesClient) CheckNameAvailabilityMethodPreparer(parameters Ch return preparer.Prepare(&http.Request{}) } -// CheckNameAvailabilityMethodSender sends the CheckNameAvailabilityMethod request. The method will close the +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the // http.Response Body if it receives an error. -func (client NamespacesClient) CheckNameAvailabilityMethodSender(req *http.Request) (*http.Response, error) { +func (client NamespacesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// CheckNameAvailabilityMethodResponder handles the response to the CheckNameAvailabilityMethod request. The method always +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always // closes the http.Response Body. -func (client NamespacesClient) CheckNameAvailabilityMethodResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { +func (client NamespacesClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -116,41 +118,59 @@ func (client NamespacesClient) CheckNameAvailabilityMethodResponder(resp *http.R // cancel channel argument. The channel will be used to cancel polling and any // outstanding HTTP requests. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name parameters is parameters +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name parameters is parameters // for creating a namespace resource. -func (client NamespacesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, parameters Namespace, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client NamespacesClient) CreateOrUpdate(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (<-chan NamespaceResource, <-chan error) { + resultChan := make(chan NamespaceResource, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: namespaceName, Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, parameters, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result NamespaceResource + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client NamespacesClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, parameters Namespace, cancel <-chan struct{}) (*http.Request, error) { +func (client NamespacesClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ "namespaceName": autorest.Encode("path", namespaceName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -182,24 +202,25 @@ func (client NamespacesClient) CreateOrUpdateSender(req *http.Request) (*http.Re // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result NamespaceResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// CreateOrUpdateAuthorizationRule creates or updates an authorization rule for -// a namespace. +// CreateOrUpdateAuthorizationRule creates or updates an AuthorizationRule for +// a Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name authorizationRuleName is -// the authorizationrule name. parameters is the shared access authorization -// rule. -func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRule) (result SharedAccessAuthorizationRule, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. parameters is the shared access +// AuthorizationRule. +func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -218,13 +239,15 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) @@ -236,7 +259,7 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRule(resourceGroupName } // CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request. -func (client NamespacesClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRule) (*http.Request, error) { +func (client NamespacesClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ "authorizationRuleName": autorest.Encode("path", authorizationRuleName), "namespaceName": autorest.Encode("path", namespaceName), @@ -267,7 +290,7 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRuleSender(req *http.R // CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always // closes the http.Response Body. -func (client NamespacesClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRule, err error) { +func (client NamespacesClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -284,9 +307,11 @@ func (client NamespacesClient) CreateOrUpdateAuthorizationRuleResponder(resp *ht // The channel will be used to cancel polling and any outstanding HTTP // requests. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name -func (client NamespacesClient) Delete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name +func (client NamespacesClient) Delete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -294,26 +319,40 @@ func (client NamespacesClient) Delete(resourceGroupName string, namespaceName st {TargetValue: namespaceName, Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "Delete") - } - - req, err := client.DeletePreparer(resourceGroupName, namespaceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, namespaceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -357,11 +396,11 @@ func (client NamespacesClient) DeleteResponder(resp *http.Response) (result auto return } -// DeleteAuthorizationRule deletes an authorization rule for a namespace. +// DeleteAuthorizationRule deletes an AuthorizationRule for a Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name authorizationRuleName is -// the authorizationrule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. func (client NamespacesClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string) (result autorest.Response, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -378,13 +417,15 @@ func (client NamespacesClient) DeleteAuthorizationRule(resourceGroupName string, req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.DeleteAuthorizationRuleSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request") + return } result, err = client.DeleteAuthorizationRuleResponder(resp) @@ -437,9 +478,9 @@ func (client NamespacesClient) DeleteAuthorizationRuleResponder(resp *http.Respo // Get gets the description of the specified namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name -func (client NamespacesClient) Get(resourceGroupName string, namespaceName string) (result Namespace, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name +func (client NamespacesClient) Get(resourceGroupName string, namespaceName string) (result NamespaceResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -452,13 +493,15 @@ func (client NamespacesClient) Get(resourceGroupName string, namespaceName strin req, err := client.GetPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -498,24 +541,23 @@ func (client NamespacesClient) GetSender(req *http.Request) (*http.Response, err // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client NamespacesClient) GetResponder(resp *http.Response) (result Namespace, err error) { +func (client NamespacesClient) GetResponder(resp *http.Response) (result NamespaceResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } -// GetAuthorizationRule gets an authorization rule for a namespace by rule -// name. +// GetAuthorizationRule gets an AuthorizationRule for a Namespace by rule name. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name authorizationRuleName is -// the authorizationrule name. -func (client NamespacesClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string) (result SharedAccessAuthorizationRule, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. +func (client NamespacesClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -531,13 +573,15 @@ func (client NamespacesClient) GetAuthorizationRule(resourceGroupName string, na req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") + return } resp, err := client.GetAuthorizationRuleSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request") + return } result, err = client.GetAuthorizationRuleResponder(resp) @@ -578,7 +622,7 @@ func (client NamespacesClient) GetAuthorizationRuleSender(req *http.Request) (*h // GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always // closes the http.Response Body. -func (client NamespacesClient) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRule, err error) { +func (client NamespacesClient) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -589,32 +633,48 @@ func (client NamespacesClient) GetAuthorizationRuleResponder(resp *http.Response return } -// List lists all the available namespaces within a subscription, irrespective -// of the resource groups. -func (client NamespacesClient) List() (result NamespaceListResult, err error) { - req, err := client.ListPreparer() +// ListAuthorizationRules gets a list of authorization rules for a Namespace. +// +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name +func (client NamespacesClient) ListAuthorizationRules(resourceGroupName string, namespaceName string) (result SharedAccessAuthorizationRuleListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "ListAuthorizationRules") + } + + req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") + return } - resp, err := client.ListSender(req) + resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request") + return } - result, err = client.ListResponder(resp) + result, err = client.ListAuthorizationRulesResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "List", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure responding to request") } return } -// ListPreparer prepares the List request. -func (client NamespacesClient) ListPreparer() (*http.Request, error) { +// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. +func (client NamespacesClient) ListAuthorizationRulesPreparer(resourceGroupName string, namespaceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "namespaceName": autorest.Encode("path", namespaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2015-08-01" @@ -625,20 +685,20 @@ func (client NamespacesClient) ListPreparer() (*http.Request, error) { preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventHub/namespaces", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListSender sends the List request. The method will close the +// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the // http.Response Body if it receives an error. -func (client NamespacesClient) ListSender(req *http.Request) (*http.Response, error) { +func (client NamespacesClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListResponder handles the response to the List request. The method always +// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always // closes the http.Response Body. -func (client NamespacesClient) ListResponder(resp *http.Response) (result NamespaceListResult, err error) { +func (client NamespacesClient) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -649,68 +709,66 @@ func (client NamespacesClient) ListResponder(resp *http.Response) (result Namesp return } -// ListNextResults retrieves the next set of results, if any. -func (client NamespacesClient) ListNextResults(lastResults NamespaceListResult) (result NamespaceListResult, err error) { - req, err := lastResults.NamespaceListResultPreparer() +// ListAuthorizationRulesNextResults retrieves the next set of results, if any. +func (client NamespacesClient) ListAuthorizationRulesNextResults(lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) { + req, err := lastResults.SharedAccessAuthorizationRuleListResultPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "List", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListSender(req) + resp, err := client.ListAuthorizationRulesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "List", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending next results request") } - result, err = client.ListResponder(resp) + result, err = client.ListAuthorizationRulesResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "List", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure responding to next results request") } return } -// ListAuthorizationRules gets a list of authorization rules for a namespace. +// ListByResourceGroup lists the available Namespaces within a resource group. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name -func (client NamespacesClient) ListAuthorizationRules(resourceGroupName string, namespaceName string) (result SharedAccessAuthorizationRuleListResult, err error) { +// resourceGroupName is name of the resource group within the azure +// subscription. +func (client NamespacesClient) ListByResourceGroup(resourceGroupName string) (result NamespaceListResult, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "ListAuthorizationRules") + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "ListByResourceGroup") } - req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName) + req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return } - resp, err := client.ListAuthorizationRulesSender(req) + resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request") + return } - result, err = client.ListAuthorizationRulesResponder(resp) + result, err = client.ListByResourceGroupResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure responding to request") } return } -// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. -func (client NamespacesClient) ListAuthorizationRulesPreparer(resourceGroupName string, namespaceName string) (*http.Request, error) { +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client NamespacesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -723,20 +781,20 @@ func (client NamespacesClient) ListAuthorizationRulesPreparer(resourceGroupName preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the // http.Response Body if it receives an error. -func (client NamespacesClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { +func (client NamespacesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always // closes the http.Response Body. -func (client NamespacesClient) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) { +func (client NamespacesClient) ListByResourceGroupResponder(resp *http.Response) (result NamespaceListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -747,66 +805,58 @@ func (client NamespacesClient) ListAuthorizationRulesResponder(resp *http.Respon return } -// ListAuthorizationRulesNextResults retrieves the next set of results, if any. -func (client NamespacesClient) ListAuthorizationRulesNextResults(lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) { - req, err := lastResults.SharedAccessAuthorizationRuleListResultPreparer() +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client NamespacesClient) ListByResourceGroupNextResults(lastResults NamespaceListResult) (result NamespaceListResult, err error) { + req, err := lastResults.NamespaceListResultPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListAuthorizationRulesSender(req) + resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending next results request") } - result, err = client.ListAuthorizationRulesResponder(resp) + result, err = client.ListByResourceGroupResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListAuthorizationRules", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure responding to next results request") } return } -// ListByResourceGroup lists the available namespaces within a resource group. -// -// resourceGroupName is name of the Resource group within the Azure -// subscription. -func (client NamespacesClient) ListByResourceGroup(resourceGroupName string) (result NamespaceListResult, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "eventhub.NamespacesClient", "ListByResourceGroup") - } - - req, err := client.ListByResourceGroupPreparer(resourceGroupName) +// ListBySubscription lists all the available Namespaces within a subscription, +// irrespective of the resource groups. +func (client NamespacesClient) ListBySubscription() (result NamespaceListResult, err error) { + req, err := client.ListBySubscriptionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", nil, "Failure preparing request") + return } - resp, err := client.ListByResourceGroupSender(req) + resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure sending request") + return } - result, err = client.ListByResourceGroupResponder(resp) + result, err = client.ListBySubscriptionResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure responding to request") } return } -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client NamespacesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client NamespacesClient) ListBySubscriptionPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2015-08-01" @@ -817,20 +867,20 @@ func (client NamespacesClient) ListByResourceGroupPreparer(resourceGroupName str preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventHub/namespaces", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare(&http.Request{}) } -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the // http.Response Body if it receives an error. -func (client NamespacesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { +func (client NamespacesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req) } -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always // closes the http.Response Body. -func (client NamespacesClient) ListByResourceGroupResponder(resp *http.Response) (result NamespaceListResult, err error) { +func (client NamespacesClient) ListBySubscriptionResponder(resp *http.Response) (result NamespaceListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -841,36 +891,36 @@ func (client NamespacesClient) ListByResourceGroupResponder(resp *http.Response) return } -// ListByResourceGroupNextResults retrieves the next set of results, if any. -func (client NamespacesClient) ListByResourceGroupNextResults(lastResults NamespaceListResult) (result NamespaceListResult, err error) { +// ListBySubscriptionNextResults retrieves the next set of results, if any. +func (client NamespacesClient) ListBySubscriptionNextResults(lastResults NamespaceListResult) (result NamespaceListResult, err error) { req, err := lastResults.NamespaceListResultPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing next results request") + return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", nil, "Failure preparing next results request") } if req == nil { return } - resp, err := client.ListByResourceGroupSender(req) + resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure sending next results request") + return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure sending next results request") } - result, err = client.ListByResourceGroupResponder(resp) + result, err = client.ListBySubscriptionResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListByResourceGroup", resp, "Failure responding to next results request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListBySubscription", resp, "Failure responding to next results request") } return } // ListKeys gets the primary and secondary connection strings for the -// namespace. +// Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name authorizationRuleName is -// the authorizationrule name. +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. func (client NamespacesClient) ListKeys(resourceGroupName string, namespaceName string, authorizationRuleName string) (result ResourceListKeys, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, @@ -887,13 +937,15 @@ func (client NamespacesClient) ListKeys(resourceGroupName string, namespaceName req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) @@ -946,11 +998,11 @@ func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result Re } // RegenerateKeys regenerates the primary or secondary connection strings for -// the specified namespace. +// the specified Namespace. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name authorizationRuleName is -// the authorizationrule name. parameters is parameters required to regenerate +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name authorizationRuleName is +// the authorization rule name. parameters is parameters required to regenerate // the connection string. func (client NamespacesClient) RegenerateKeys(resourceGroupName string, namespaceName string, authorizationRuleName string, parameters RegenerateKeysParameters) (result ResourceListKeys, err error) { if err := validation.Validate([]validation.Validation{ @@ -968,13 +1020,15 @@ func (client NamespacesClient) RegenerateKeys(resourceGroupName string, namespac req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, authorizationRuleName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") + return } resp, err := client.RegenerateKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "RegenerateKeys", resp, "Failure sending request") + return } result, err = client.RegenerateKeysResponder(resp) @@ -1031,10 +1085,10 @@ func (client NamespacesClient) RegenerateKeysResponder(resp *http.Response) (res // Update creates or updates a namespace. Once created, this namespace's // resource manifest is immutable. This operation is idempotent. // -// resourceGroupName is name of the Resource group within the Azure -// subscription. namespaceName is the namespace name parameters is parameters +// resourceGroupName is name of the resource group within the azure +// subscription. namespaceName is the Namespace name parameters is parameters // for updating a namespace resource. -func (client NamespacesClient) Update(resourceGroupName string, namespaceName string, parameters NamespaceUpdateParameter) (result Namespace, err error) { +func (client NamespacesClient) Update(resourceGroupName string, namespaceName string, parameters NamespaceUpdateParameter) (result NamespaceResource, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, @@ -1047,13 +1101,15 @@ func (client NamespacesClient) Update(resourceGroupName string, namespaceName st req, err := client.UpdatePreparer(resourceGroupName, namespaceName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -1095,7 +1151,7 @@ func (client NamespacesClient) UpdateSender(req *http.Request) (*http.Response, // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. -func (client NamespacesClient) UpdateResponder(resp *http.Response) (result Namespace, err error) { +func (client NamespacesClient) UpdateResponder(resp *http.Response) (result NamespaceResource, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/arm/eventhub/operations.go b/arm/eventhub/operations.go index 04a01708005c..c86a01619860 100755 --- a/arm/eventhub/operations.go +++ b/arm/eventhub/operations.go @@ -40,17 +40,19 @@ func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) Opera return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// List lists all of the available event hub REST API operations. +// List lists all of the available Event Hub REST API operations. func (client OperationsClient) List() (result OperationListResult, err error) { req, err := client.ListPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "eventhub.OperationsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/eventhub/version.go b/arm/eventhub/version.go index 16c7ea2328e1..485ffc635941 100755 --- a/arm/eventhub/version.go +++ b/arm/eventhub/version.go @@ -20,10 +20,10 @@ package eventhub // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-eventhub/2015-08-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-eventhub/2015-08-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/graphrbac/applications.go b/arm/graphrbac/applications.go index 77858a81452f..cb0fad4d5876 100644 --- a/arm/graphrbac/applications.go +++ b/arm/graphrbac/applications.go @@ -25,7 +25,8 @@ import ( "net/http" ) -// ApplicationsClient is the the Graph RBAC Management Client +// ApplicationsClient is the composite Swagger specification for Azure Active +// Directory Graph RBAC management client. type ApplicationsClient struct { ManagementClient } @@ -55,13 +56,15 @@ func (client ApplicationsClient) Create(parameters ApplicationCreateParameters) req, err := client.CreatePreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -78,8 +81,9 @@ func (client ApplicationsClient) CreatePreparer(parameters ApplicationCreatePara "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -117,13 +121,15 @@ func (client ApplicationsClient) CreateResponder(resp *http.Response) (result Ap func (client ApplicationsClient) Delete(applicationObjectID string) (result autorest.Response, err error) { req, err := client.DeletePreparer(applicationObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -141,8 +147,9 @@ func (client ApplicationsClient) DeletePreparer(applicationObjectID string) (*ht "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -177,13 +184,15 @@ func (client ApplicationsClient) DeleteResponder(resp *http.Response) (result au func (client ApplicationsClient) Get(applicationObjectID string) (result Application, err error) { req, err := client.GetPreparer(applicationObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -201,8 +210,9 @@ func (client ApplicationsClient) GetPreparer(applicationObjectID string) (*http. "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -238,13 +248,15 @@ func (client ApplicationsClient) GetResponder(resp *http.Response) (result Appli func (client ApplicationsClient) List(filter string) (result ApplicationListResult, err error) { req, err := client.ListPreparer(filter) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -261,8 +273,9 @@ func (client ApplicationsClient) ListPreparer(filter string) (*http.Request, err "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -301,13 +314,15 @@ func (client ApplicationsClient) ListResponder(resp *http.Response) (result Appl func (client ApplicationsClient) ListKeyCredentials(applicationObjectID string) (result KeyCredentialListResult, err error) { req, err := client.ListKeyCredentialsPreparer(applicationObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListKeyCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListKeyCredentials", nil, "Failure preparing request") + return } resp, err := client.ListKeyCredentialsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListKeyCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListKeyCredentials", resp, "Failure sending request") + return } result, err = client.ListKeyCredentialsResponder(resp) @@ -325,8 +340,9 @@ func (client ApplicationsClient) ListKeyCredentialsPreparer(applicationObjectID "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -362,13 +378,15 @@ func (client ApplicationsClient) ListKeyCredentialsResponder(resp *http.Response func (client ApplicationsClient) ListNext(nextLink string) (result ApplicationListResult, err error) { req, err := client.ListNextPreparer(nextLink) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListNext", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListNext", nil, "Failure preparing request") + return } resp, err := client.ListNextSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListNext", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListNext", resp, "Failure sending request") + return } result, err = client.ListNextResponder(resp) @@ -386,8 +404,9 @@ func (client ApplicationsClient) ListNextPreparer(nextLink string) (*http.Reques "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -424,13 +443,15 @@ func (client ApplicationsClient) ListNextResponder(resp *http.Response) (result func (client ApplicationsClient) ListPasswordCredentials(applicationObjectID string) (result PasswordCredentialListResult, err error) { req, err := client.ListPasswordCredentialsPreparer(applicationObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListPasswordCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListPasswordCredentials", nil, "Failure preparing request") + return } resp, err := client.ListPasswordCredentialsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListPasswordCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "ListPasswordCredentials", resp, "Failure sending request") + return } result, err = client.ListPasswordCredentialsResponder(resp) @@ -448,8 +469,9 @@ func (client ApplicationsClient) ListPasswordCredentialsPreparer(applicationObje "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -486,13 +508,15 @@ func (client ApplicationsClient) ListPasswordCredentialsResponder(resp *http.Res func (client ApplicationsClient) Patch(applicationObjectID string, parameters ApplicationUpdateParameters) (result autorest.Response, err error) { req, err := client.PatchPreparer(applicationObjectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Patch", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Patch", nil, "Failure preparing request") + return } resp, err := client.PatchSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Patch", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "Patch", resp, "Failure sending request") + return } result, err = client.PatchResponder(resp) @@ -510,8 +534,9 @@ func (client ApplicationsClient) PatchPreparer(applicationObjectID string, param "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -550,13 +575,15 @@ func (client ApplicationsClient) PatchResponder(resp *http.Response) (result aut func (client ApplicationsClient) UpdateKeyCredentials(applicationObjectID string, parameters KeyCredentialsUpdateParameters) (result autorest.Response, err error) { req, err := client.UpdateKeyCredentialsPreparer(applicationObjectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdateKeyCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdateKeyCredentials", nil, "Failure preparing request") + return } resp, err := client.UpdateKeyCredentialsSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdateKeyCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdateKeyCredentials", resp, "Failure sending request") + return } result, err = client.UpdateKeyCredentialsResponder(resp) @@ -574,8 +601,9 @@ func (client ApplicationsClient) UpdateKeyCredentialsPreparer(applicationObjectI "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -614,13 +642,15 @@ func (client ApplicationsClient) UpdateKeyCredentialsResponder(resp *http.Respon func (client ApplicationsClient) UpdatePasswordCredentials(applicationObjectID string, parameters PasswordCredentialsUpdateParameters) (result autorest.Response, err error) { req, err := client.UpdatePasswordCredentialsPreparer(applicationObjectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdatePasswordCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdatePasswordCredentials", nil, "Failure preparing request") + return } resp, err := client.UpdatePasswordCredentialsSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdatePasswordCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ApplicationsClient", "UpdatePasswordCredentials", resp, "Failure sending request") + return } result, err = client.UpdatePasswordCredentialsResponder(resp) @@ -638,8 +668,9 @@ func (client ApplicationsClient) UpdatePasswordCredentialsPreparer(applicationOb "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/graphrbac/client.go b/arm/graphrbac/client.go index cad41f187f53..282c2af0dbdd 100644 --- a/arm/graphrbac/client.go +++ b/arm/graphrbac/client.go @@ -1,7 +1,7 @@ -// Package graphrbac implements the Azure ARM Graphrbac service API version -// 1.6. +// Package graphrbac implements the Azure ARM Graphrbac service API version . // -// The Graph RBAC Management Client +// Composite Swagger specification for Azure Active Directory Graph RBAC +// management client. package graphrbac // Copyright (c) Microsoft and contributors. All rights reserved. @@ -27,9 +27,6 @@ import ( ) const ( - // APIVersion is the version of the Graphrbac - APIVersion = "1.6" - // DefaultBaseURI is the default URI used for the service Graphrbac DefaultBaseURI = "https://graph.windows.net" ) @@ -37,9 +34,8 @@ const ( // ManagementClient is the base client for Graphrbac. type ManagementClient struct { autorest.Client - BaseURI string - APIVersion string - TenantID string + BaseURI string + TenantID string } // New creates an instance of the ManagementClient client. @@ -50,9 +46,8 @@ func New(tenantID string) ManagementClient { // NewWithBaseURI creates an instance of the ManagementClient client. func NewWithBaseURI(baseURI string, tenantID string) ManagementClient { return ManagementClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - APIVersion: APIVersion, - TenantID: tenantID, + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + TenantID: tenantID, } } diff --git a/arm/graphrbac/groups.go b/arm/graphrbac/groups.go index 25623b368462..6c26e0805f07 100644 --- a/arm/graphrbac/groups.go +++ b/arm/graphrbac/groups.go @@ -25,7 +25,8 @@ import ( "net/http" ) -// GroupsClient is the the Graph RBAC Management Client +// GroupsClient is the composite Swagger specification for Azure Active +// Directory Graph RBAC management client. type GroupsClient struct { ManagementClient } @@ -54,13 +55,15 @@ func (client GroupsClient) AddMember(groupObjectID string, parameters GroupAddMe req, err := client.AddMemberPreparer(groupObjectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "AddMember", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "AddMember", nil, "Failure preparing request") + return } resp, err := client.AddMemberSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "AddMember", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "AddMember", resp, "Failure sending request") + return } result, err = client.AddMemberResponder(resp) @@ -78,8 +81,9 @@ func (client GroupsClient) AddMemberPreparer(groupObjectID string, parameters Gr "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -125,13 +129,15 @@ func (client GroupsClient) Create(parameters GroupCreateParameters) (result ADGr req, err := client.CreatePreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -148,8 +154,9 @@ func (client GroupsClient) CreatePreparer(parameters GroupCreateParameters) (*ht "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -187,13 +194,15 @@ func (client GroupsClient) CreateResponder(resp *http.Response) (result ADGroup, func (client GroupsClient) Delete(groupObjectID string) (result autorest.Response, err error) { req, err := client.DeletePreparer(groupObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -211,8 +220,9 @@ func (client GroupsClient) DeletePreparer(groupObjectID string) (*http.Request, "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -247,13 +257,15 @@ func (client GroupsClient) DeleteResponder(resp *http.Response) (result autorest func (client GroupsClient) Get(objectID string) (result ADGroup, err error) { req, err := client.GetPreparer(objectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -271,8 +283,9 @@ func (client GroupsClient) GetPreparer(objectID string) (*http.Request, error) { "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -308,13 +321,15 @@ func (client GroupsClient) GetResponder(resp *http.Response) (result ADGroup, er func (client GroupsClient) GetGroupMembers(objectID string) (result GetObjectsResult, err error) { req, err := client.GetGroupMembersPreparer(objectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembers", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembers", nil, "Failure preparing request") + return } resp, err := client.GetGroupMembersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembers", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembers", resp, "Failure sending request") + return } result, err = client.GetGroupMembersResponder(resp) @@ -332,8 +347,9 @@ func (client GroupsClient) GetGroupMembersPreparer(objectID string) (*http.Reque "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -369,13 +385,15 @@ func (client GroupsClient) GetGroupMembersResponder(resp *http.Response) (result func (client GroupsClient) GetGroupMembersNext(nextLink string) (result GetObjectsResult, err error) { req, err := client.GetGroupMembersNextPreparer(nextLink) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembersNext", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembersNext", nil, "Failure preparing request") + return } resp, err := client.GetGroupMembersNextSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembersNext", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetGroupMembersNext", resp, "Failure sending request") + return } result, err = client.GetGroupMembersNextResponder(resp) @@ -393,8 +411,9 @@ func (client GroupsClient) GetGroupMembersNextPreparer(nextLink string) (*http.R "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -438,13 +457,15 @@ func (client GroupsClient) GetMemberGroups(objectID string, parameters GroupGetM req, err := client.GetMemberGroupsPreparer(objectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetMemberGroups", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetMemberGroups", nil, "Failure preparing request") + return } resp, err := client.GetMemberGroupsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetMemberGroups", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "GetMemberGroups", resp, "Failure sending request") + return } result, err = client.GetMemberGroupsResponder(resp) @@ -462,8 +483,9 @@ func (client GroupsClient) GetMemberGroupsPreparer(objectID string, parameters G "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -509,13 +531,15 @@ func (client GroupsClient) IsMemberOf(parameters CheckGroupMembershipParameters) req, err := client.IsMemberOfPreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "IsMemberOf", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "IsMemberOf", nil, "Failure preparing request") + return } resp, err := client.IsMemberOfSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "IsMemberOf", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "IsMemberOf", resp, "Failure sending request") + return } result, err = client.IsMemberOfResponder(resp) @@ -532,8 +556,9 @@ func (client GroupsClient) IsMemberOfPreparer(parameters CheckGroupMembershipPar "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -571,13 +596,15 @@ func (client GroupsClient) IsMemberOfResponder(resp *http.Response) (result Chec func (client GroupsClient) List(filter string) (result GroupListResult, err error) { req, err := client.ListPreparer(filter) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -594,8 +621,9 @@ func (client GroupsClient) ListPreparer(filter string) (*http.Request, error) { "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -634,13 +662,15 @@ func (client GroupsClient) ListResponder(resp *http.Response) (result GroupListR func (client GroupsClient) ListNext(nextLink string) (result GroupListResult, err error) { req, err := client.ListNextPreparer(nextLink) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "ListNext", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "ListNext", nil, "Failure preparing request") + return } resp, err := client.ListNextSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "ListNext", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "ListNext", resp, "Failure sending request") + return } result, err = client.ListNextResponder(resp) @@ -658,8 +688,9 @@ func (client GroupsClient) ListNextPreparer(nextLink string) (*http.Request, err "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -696,13 +727,15 @@ func (client GroupsClient) ListNextResponder(resp *http.Response) (result GroupL func (client GroupsClient) RemoveMember(groupObjectID string, memberObjectID string) (result autorest.Response, err error) { req, err := client.RemoveMemberPreparer(groupObjectID, memberObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "RemoveMember", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "RemoveMember", nil, "Failure preparing request") + return } resp, err := client.RemoveMemberSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "RemoveMember", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.GroupsClient", "RemoveMember", resp, "Failure sending request") + return } result, err = client.RemoveMemberResponder(resp) @@ -721,8 +754,9 @@ func (client GroupsClient) RemoveMemberPreparer(groupObjectID string, memberObje "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/graphrbac/models.go b/arm/graphrbac/models.go index 6fe5b4ba39ac..ab8775a7237e 100644 --- a/arm/graphrbac/models.go +++ b/arm/graphrbac/models.go @@ -111,6 +111,14 @@ type ErrorMessage struct { Message *string `json:"value,omitempty"` } +// GetObjectsParameters is request parameters for the GetObjectsByObjectIds +// API. +type GetObjectsParameters struct { + ObjectIds *[]string `json:"objectIds,omitempty"` + Types *[]string `json:"types,omitempty"` + IncludeDirectoryObjectReferences *bool `json:"includeDirectoryObjectReferences,omitempty"` +} + // GetObjectsResult is the response to an Active Directory object inquiry API // request. type GetObjectsResult struct { diff --git a/arm/graphrbac/objects.go b/arm/graphrbac/objects.go index 0b93abdcd3c3..b0a7e94dae27 100644 --- a/arm/graphrbac/objects.go +++ b/arm/graphrbac/objects.go @@ -21,10 +21,12 @@ package graphrbac import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" "net/http" ) -// ObjectsClient is the the Graph RBAC Management Client +// ObjectsClient is the composite Swagger specification for Azure Active +// Directory Graph RBAC management client. type ObjectsClient struct { ManagementClient } @@ -43,13 +45,15 @@ func NewObjectsClientWithBaseURI(baseURI string, tenantID string) ObjectsClient func (client ObjectsClient) GetCurrentUser() (result AADObject, err error) { req, err := client.GetCurrentUserPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", nil, "Failure preparing request") + return } resp, err := client.GetCurrentUserSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", resp, "Failure sending request") + return } result, err = client.GetCurrentUserResponder(resp) @@ -66,8 +70,9 @@ func (client ObjectsClient) GetCurrentUserPreparer() (*http.Request, error) { "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -96,3 +101,140 @@ func (client ObjectsClient) GetCurrentUserResponder(resp *http.Response) (result result.Response = autorest.Response{Response: resp} return } + +// GetObjectsByObjectIds gets AD group membership for the specified AD object +// IDs. +// +// parameters is objects filtering parameters. +func (client ObjectsClient) GetObjectsByObjectIds(parameters GetObjectsParameters) (result GetObjectsResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.IncludeDirectoryObjectReferences", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds") + } + + req, err := client.GetObjectsByObjectIdsPreparer(parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", nil, "Failure preparing request") + return + } + + resp, err := client.GetObjectsByObjectIdsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", resp, "Failure sending request") + return + } + + result, err = client.GetObjectsByObjectIdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", resp, "Failure responding to request") + } + + return +} + +// GetObjectsByObjectIdsPreparer prepares the GetObjectsByObjectIds request. +func (client ObjectsClient) GetObjectsByObjectIdsPreparer(parameters GetObjectsParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/getObjectsByObjectIds", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetObjectsByObjectIdsSender sends the GetObjectsByObjectIds request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectsClient) GetObjectsByObjectIdsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetObjectsByObjectIdsResponder handles the response to the GetObjectsByObjectIds request. The method always +// closes the http.Response Body. +func (client ObjectsClient) GetObjectsByObjectIdsResponder(resp *http.Response) (result GetObjectsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetObjectsByObjectIdsNext gets AD group membership for the specified AD +// object IDs. +// +// nextLink is next link for the list operation. +func (client ObjectsClient) GetObjectsByObjectIdsNext(nextLink string) (result GetObjectsResult, err error) { + req, err := client.GetObjectsByObjectIdsNextPreparer(nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIdsNext", nil, "Failure preparing request") + return + } + + resp, err := client.GetObjectsByObjectIdsNextSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIdsNext", resp, "Failure sending request") + return + } + + result, err = client.GetObjectsByObjectIdsNextResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIdsNext", resp, "Failure responding to request") + } + + return +} + +// GetObjectsByObjectIdsNextPreparer prepares the GetObjectsByObjectIdsNext request. +func (client ObjectsClient) GetObjectsByObjectIdsNextPreparer(nextLink string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "nextLink": nextLink, + "tenantID": autorest.Encode("path", client.TenantID), + } + + const APIVersion = "1.6" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{tenantID}/{nextLink}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetObjectsByObjectIdsNextSender sends the GetObjectsByObjectIdsNext request. The method will close the +// http.Response Body if it receives an error. +func (client ObjectsClient) GetObjectsByObjectIdsNextSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetObjectsByObjectIdsNextResponder handles the response to the GetObjectsByObjectIdsNext request. The method always +// closes the http.Response Body. +func (client ObjectsClient) GetObjectsByObjectIdsNextResponder(resp *http.Response) (result GetObjectsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/graphrbac/serviceprincipals.go b/arm/graphrbac/serviceprincipals.go index dab21566c870..57a173968c5d 100644 --- a/arm/graphrbac/serviceprincipals.go +++ b/arm/graphrbac/serviceprincipals.go @@ -25,7 +25,8 @@ import ( "net/http" ) -// ServicePrincipalsClient is the the Graph RBAC Management Client +// ServicePrincipalsClient is the composite Swagger specification for Azure +// Active Directory Graph RBAC management client. type ServicePrincipalsClient struct { ManagementClient } @@ -55,13 +56,15 @@ func (client ServicePrincipalsClient) Create(parameters ServicePrincipalCreatePa req, err := client.CreatePreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -78,8 +81,9 @@ func (client ServicePrincipalsClient) CreatePreparer(parameters ServicePrincipal "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -117,13 +121,15 @@ func (client ServicePrincipalsClient) CreateResponder(resp *http.Response) (resu func (client ServicePrincipalsClient) Delete(objectID string) (result autorest.Response, err error) { req, err := client.DeletePreparer(objectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -141,8 +147,9 @@ func (client ServicePrincipalsClient) DeletePreparer(objectID string) (*http.Req "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -177,13 +184,15 @@ func (client ServicePrincipalsClient) DeleteResponder(resp *http.Response) (resu func (client ServicePrincipalsClient) Get(objectID string) (result ServicePrincipal, err error) { req, err := client.GetPreparer(objectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -201,8 +210,9 @@ func (client ServicePrincipalsClient) GetPreparer(objectID string) (*http.Reques "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -238,13 +248,15 @@ func (client ServicePrincipalsClient) GetResponder(resp *http.Response) (result func (client ServicePrincipalsClient) List(filter string) (result ServicePrincipalListResult, err error) { req, err := client.ListPreparer(filter) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -261,8 +273,9 @@ func (client ServicePrincipalsClient) ListPreparer(filter string) (*http.Request "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -303,13 +316,15 @@ func (client ServicePrincipalsClient) ListResponder(resp *http.Response) (result func (client ServicePrincipalsClient) ListKeyCredentials(objectID string) (result KeyCredentialListResult, err error) { req, err := client.ListKeyCredentialsPreparer(objectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListKeyCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListKeyCredentials", nil, "Failure preparing request") + return } resp, err := client.ListKeyCredentialsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListKeyCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListKeyCredentials", resp, "Failure sending request") + return } result, err = client.ListKeyCredentialsResponder(resp) @@ -327,8 +342,9 @@ func (client ServicePrincipalsClient) ListKeyCredentialsPreparer(objectID string "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -364,13 +380,15 @@ func (client ServicePrincipalsClient) ListKeyCredentialsResponder(resp *http.Res func (client ServicePrincipalsClient) ListNext(nextLink string) (result ServicePrincipalListResult, err error) { req, err := client.ListNextPreparer(nextLink) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListNext", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListNext", nil, "Failure preparing request") + return } resp, err := client.ListNextSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListNext", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListNext", resp, "Failure sending request") + return } result, err = client.ListNextResponder(resp) @@ -388,8 +406,9 @@ func (client ServicePrincipalsClient) ListNextPreparer(nextLink string) (*http.R "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -426,13 +445,15 @@ func (client ServicePrincipalsClient) ListNextResponder(resp *http.Response) (re func (client ServicePrincipalsClient) ListPasswordCredentials(objectID string) (result PasswordCredentialListResult, err error) { req, err := client.ListPasswordCredentialsPreparer(objectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListPasswordCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListPasswordCredentials", nil, "Failure preparing request") + return } resp, err := client.ListPasswordCredentialsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListPasswordCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "ListPasswordCredentials", resp, "Failure sending request") + return } result, err = client.ListPasswordCredentialsResponder(resp) @@ -450,8 +471,9 @@ func (client ServicePrincipalsClient) ListPasswordCredentialsPreparer(objectID s "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -490,13 +512,15 @@ func (client ServicePrincipalsClient) ListPasswordCredentialsResponder(resp *htt func (client ServicePrincipalsClient) UpdateKeyCredentials(objectID string, parameters KeyCredentialsUpdateParameters) (result autorest.Response, err error) { req, err := client.UpdateKeyCredentialsPreparer(objectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdateKeyCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdateKeyCredentials", nil, "Failure preparing request") + return } resp, err := client.UpdateKeyCredentialsSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdateKeyCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdateKeyCredentials", resp, "Failure sending request") + return } result, err = client.UpdateKeyCredentialsResponder(resp) @@ -514,8 +538,9 @@ func (client ServicePrincipalsClient) UpdateKeyCredentialsPreparer(objectID stri "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -554,13 +579,15 @@ func (client ServicePrincipalsClient) UpdateKeyCredentialsResponder(resp *http.R func (client ServicePrincipalsClient) UpdatePasswordCredentials(objectID string, parameters PasswordCredentialsUpdateParameters) (result autorest.Response, err error) { req, err := client.UpdatePasswordCredentialsPreparer(objectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdatePasswordCredentials", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdatePasswordCredentials", nil, "Failure preparing request") + return } resp, err := client.UpdatePasswordCredentialsSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdatePasswordCredentials", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.ServicePrincipalsClient", "UpdatePasswordCredentials", resp, "Failure sending request") + return } result, err = client.UpdatePasswordCredentialsResponder(resp) @@ -578,8 +605,9 @@ func (client ServicePrincipalsClient) UpdatePasswordCredentialsPreparer(objectID "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/graphrbac/users.go b/arm/graphrbac/users.go index 2a91e633f128..5722cb92ae0f 100644 --- a/arm/graphrbac/users.go +++ b/arm/graphrbac/users.go @@ -25,7 +25,8 @@ import ( "net/http" ) -// UsersClient is the the Graph RBAC Management Client +// UsersClient is the composite Swagger specification for Azure Active +// Directory Graph RBAC management client. type UsersClient struct { ManagementClient } @@ -57,13 +58,15 @@ func (client UsersClient) Create(parameters UserCreateParameters) (result User, req, err := client.CreatePreparer(parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Create", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Create", nil, "Failure preparing request") + return } resp, err := client.CreateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Create", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Create", resp, "Failure sending request") + return } result, err = client.CreateResponder(resp) @@ -80,8 +83,9 @@ func (client UsersClient) CreatePreparer(parameters UserCreateParameters) (*http "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -119,13 +123,15 @@ func (client UsersClient) CreateResponder(resp *http.Response) (result User, err func (client UsersClient) Delete(upnOrObjectID string) (result autorest.Response, err error) { req, err := client.DeletePreparer(upnOrObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -143,8 +149,9 @@ func (client UsersClient) DeletePreparer(upnOrObjectID string) (*http.Request, e "upnOrObjectId": upnOrObjectID, } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -180,13 +187,15 @@ func (client UsersClient) DeleteResponder(resp *http.Response) (result autorest. func (client UsersClient) Get(upnOrObjectID string) (result User, err error) { req, err := client.GetPreparer(upnOrObjectID) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -204,8 +213,9 @@ func (client UsersClient) GetPreparer(upnOrObjectID string) (*http.Request, erro "upnOrObjectId": upnOrObjectID, } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -249,13 +259,15 @@ func (client UsersClient) GetMemberGroups(objectID string, parameters UserGetMem req, err := client.GetMemberGroupsPreparer(objectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "GetMemberGroups", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "GetMemberGroups", nil, "Failure preparing request") + return } resp, err := client.GetMemberGroupsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "GetMemberGroups", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "GetMemberGroups", resp, "Failure sending request") + return } result, err = client.GetMemberGroupsResponder(resp) @@ -273,8 +285,9 @@ func (client UsersClient) GetMemberGroupsPreparer(objectID string, parameters Us "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -312,13 +325,15 @@ func (client UsersClient) GetMemberGroupsResponder(resp *http.Response) (result func (client UsersClient) List(filter string) (result UserListResult, err error) { req, err := client.ListPreparer(filter) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -335,8 +350,9 @@ func (client UsersClient) ListPreparer(filter string) (*http.Request, error) { "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -375,13 +391,15 @@ func (client UsersClient) ListResponder(resp *http.Response) (result UserListRes func (client UsersClient) ListNext(nextLink string) (result UserListResult, err error) { req, err := client.ListNextPreparer(nextLink) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "ListNext", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "ListNext", nil, "Failure preparing request") + return } resp, err := client.ListNextSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "ListNext", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "ListNext", resp, "Failure sending request") + return } result, err = client.ListNextResponder(resp) @@ -399,8 +417,9 @@ func (client UsersClient) ListNextPreparer(nextLink string) (*http.Request, erro "tenantID": autorest.Encode("path", client.TenantID), } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -437,13 +456,15 @@ func (client UsersClient) ListNextResponder(resp *http.Response) (result UserLis func (client UsersClient) Update(upnOrObjectID string, parameters UserUpdateParameters) (result autorest.Response, err error) { req, err := client.UpdatePreparer(upnOrObjectID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "graphrbac.UsersClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -461,8 +482,9 @@ func (client UsersClient) UpdatePreparer(upnOrObjectID string, parameters UserUp "upnOrObjectId": upnOrObjectID, } + const APIVersion = "1.6" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/graphrbac/version.go b/arm/graphrbac/version.go index 5bab245e134d..d8f2c5b8a281 100644 --- a/arm/graphrbac/version.go +++ b/arm/graphrbac/version.go @@ -18,43 +18,12 @@ package graphrbac // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "graphrbac", "1.6") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.0-beta arm-graphrbac/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.0-beta" } diff --git a/arm/hdinsight/applications.go b/arm/hdinsight/applications.go new file mode 100644 index 000000000000..c3a5cddc5128 --- /dev/null +++ b/arm/hdinsight/applications.go @@ -0,0 +1,352 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ApplicationsClient is the the HDInsight Management Client. +type ApplicationsClient struct { + ManagementClient +} + +// NewApplicationsClient creates an instance of the ApplicationsClient client. +func NewApplicationsClient(subscriptionID string) ApplicationsClient { + return NewApplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationsClientWithBaseURI creates an instance of the +// ApplicationsClient client. +func NewApplicationsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationsClient { + return ApplicationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create the operation creates applications for the HDInsight cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. applicationName is the constant value for the +// applicationName parameters is the application create request. +func (client ApplicationsClient) Create(resourceGroupName string, clusterName string, applicationName string, parameters ApplicationGetProperties) (result Application, err error) { + req, err := client.CreatePreparer(resourceGroupName, clusterName, applicationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ApplicationsClient) CreatePreparer(resourceGroupName string, clusterName string, applicationName string, parameters ApplicationGetProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) CreateResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete lists all of the applications HDInsight cluster. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. applicationName is the constant value for the +// applicationName. +func (client ApplicationsClient) Delete(resourceGroupName string, clusterName string, applicationName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, clusterName, applicationName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationsClient) DeletePreparer(resourceGroupName string, clusterName string, applicationName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get lists properties of the application. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. applicationName is the constant value for the +// applicationName +func (client ApplicationsClient) Get(resourceGroupName string, clusterName string, applicationName string) (result Application, err error) { + req, err := client.GetPreparer(resourceGroupName, clusterName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationsClient) GetPreparer(resourceGroupName string, clusterName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) GetResponder(resp *http.Response) (result Application, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all of the applications HDInsight cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. +func (client ApplicationsClient) List(resourceGroupName string, clusterName string) (result ApplicationListResult, err error) { + req, err := client.ListPreparer(resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ApplicationsClient) ListPreparer(resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) ListResponder(resp *http.Response) (result ApplicationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ApplicationsClient) ListNextResults(lastResults ApplicationListResult) (result ApplicationListResult, err error) { + req, err := lastResults.ApplicationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ApplicationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/hdinsight/client.go b/arm/hdinsight/client.go new file mode 100644 index 000000000000..f057af2d5901 --- /dev/null +++ b/arm/hdinsight/client.go @@ -0,0 +1,52 @@ +// Package hdinsight implements the Azure ARM Hdinsight service API version . +// +// The HDInsight Management Client. +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Hdinsight + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Hdinsight. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/arm/hdinsight/clusters.go b/arm/hdinsight/clusters.go new file mode 100644 index 000000000000..69ec386f67f5 --- /dev/null +++ b/arm/hdinsight/clusters.go @@ -0,0 +1,785 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ClustersClient is the the HDInsight Management Client. +type ClustersClient struct { + ManagementClient +} + +// NewClustersClient creates an instance of the ClustersClient client. +func NewClustersClient(subscriptionID string) ClustersClient { + return NewClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClustersClientWithBaseURI creates an instance of the ClustersClient +// client. +func NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { + return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ChangeRdpSettings begins changing the RDP settings on the specified cluster. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. parameters is the OS profile for RDP. +func (client ClustersClient) ChangeRdpSettings(resourceGroupName string, clusterName string, parameters RDPSettingsParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.Pattern, Rule: `^[0-9a-zA-Z][0-9a-zA-Z-]*[a-zA-Z0-9]$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.OsProfile", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "hdinsight.ClustersClient", "ChangeRdpSettings") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ChangeRdpSettingsPreparer(resourceGroupName, clusterName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ChangeRdpSettings", nil, "Failure preparing request") + return + } + + resp, err := client.ChangeRdpSettingsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ChangeRdpSettings", resp, "Failure sending request") + return + } + + result, err = client.ChangeRdpSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ChangeRdpSettings", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ChangeRdpSettingsPreparer prepares the ChangeRdpSettings request. +func (client ClustersClient) ChangeRdpSettingsPreparer(resourceGroupName string, clusterName string, parameters RDPSettingsParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/changerdpsetting", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ChangeRdpSettingsSender sends the ChangeRdpSettings request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ChangeRdpSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ChangeRdpSettingsResponder handles the response to the ChangeRdpSettings request. The method always +// closes the http.Response Body. +func (client ClustersClient) ChangeRdpSettingsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Create begins creating a new HDInsight cluster with the specified +// parameters. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. parameters is the cluster create request. +func (client ClustersClient) Create(resourceGroupName string, clusterName string, parameters ClusterCreateParametersExtended, cancel <-chan struct{}) (<-chan Cluster, <-chan error) { + resultChan := make(chan Cluster, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Cluster + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(resourceGroupName, clusterName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ClustersClient) CreatePreparer(resourceGroupName string, clusterName string, parameters ClusterCreateParametersExtended, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ClustersClient) CreateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete begins deleting the specified HDInsight cluster. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. +func (client ClustersClient) Delete(resourceGroupName string, clusterName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, clusterName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ClustersClient) DeletePreparer(resourceGroupName string, clusterName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ExecuteScriptActions begins executing script actions on the specified +// HDInsight cluster. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. parameters is the parameters for executing script actions. +func (client ClustersClient) ExecuteScriptActions(resourceGroupName string, clusterName string, parameters ExecuteScriptActionParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PersistOnSuccess", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "hdinsight.ClustersClient", "ExecuteScriptActions") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ExecuteScriptActionsPreparer(resourceGroupName, clusterName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ExecuteScriptActions", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteScriptActionsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ExecuteScriptActions", resp, "Failure sending request") + return + } + + result, err = client.ExecuteScriptActionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ExecuteScriptActions", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ExecuteScriptActionsPreparer prepares the ExecuteScriptActions request. +func (client ClustersClient) ExecuteScriptActionsPreparer(resourceGroupName string, clusterName string, parameters ExecuteScriptActionParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ExecuteScriptActionsSender sends the ExecuteScriptActions request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ExecuteScriptActionsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ExecuteScriptActionsResponder handles the response to the ExecuteScriptActions request. The method always +// closes the http.Response Body. +func (client ClustersClient) ExecuteScriptActionsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. +func (client ClustersClient) Get(resourceGroupName string, clusterName string) (result Cluster, err error) { + req, err := client.GetPreparer(resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ClustersClient) GetPreparer(resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ClustersClient) GetResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists HDInsight clusters under the subscription. +func (client ClustersClient) List() (result ClusterListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ClustersClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListResponder(resp *http.Response) (result ClusterListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ClustersClient) ListNextResults(lastResults ClusterListResult) (result ClusterListResult, err error) { + req, err := lastResults.ClusterListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup list the HDInsight clusters in a resource group. +// +// resourceGroupName is the name of the resource group. +func (client ClustersClient) ListByResourceGroup(resourceGroupName string) (result ClusterListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ClustersClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListByResourceGroupResponder(resp *http.Response) (result ClusterListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client ClustersClient) ListByResourceGroupNextResults(lastResults ClusterListResult) (result ClusterListResult, err error) { + req, err := lastResults.ClusterListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// Resize begins a resize operation on the specified HDInsight cluster. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. roleName is the constant value for the roleName parameters +// is the parameters for the resize operation. +func (client ClustersClient) Resize(resourceGroupName string, clusterName string, roleName string, parameters ClusterResizeParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.ResizePreparer(resourceGroupName, clusterName, roleName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Resize", nil, "Failure preparing request") + return + } + + resp, err := client.ResizeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Resize", resp, "Failure sending request") + return + } + + result, err = client.ResizeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Resize", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ResizePreparer prepares the Resize request. +func (client ClustersClient) ResizePreparer(resourceGroupName string, clusterName string, roleName string, parameters ClusterResizeParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleName": autorest.Encode("path", roleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ResizeSender sends the Resize request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ResizeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ResizeResponder handles the response to the Resize request. The method always +// closes the http.Response Body. +func (client ClustersClient) ResizeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update patch HDInsight cluster with the specified parameters. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. parameters is the cluster patch request. +func (client ClustersClient) Update(resourceGroupName string, clusterName string, parameters ClusterPatchParameters) (result Cluster, err error) { + req, err := client.UpdatePreparer(resourceGroupName, clusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ClustersClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ClustersClient) UpdatePreparer(resourceGroupName string, clusterName string, parameters ClusterPatchParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ClustersClient) UpdateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/hdinsight/configurations.go b/arm/hdinsight/configurations.go new file mode 100644 index 000000000000..a1d3ee221383 --- /dev/null +++ b/arm/hdinsight/configurations.go @@ -0,0 +1,195 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ConfigurationsClient is the the HDInsight Management Client. +type ConfigurationsClient struct { + ManagementClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient +// client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the +// ConfigurationsClient client. +func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get the configuration object for the specified cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. configurationName is the constant for configuration type of +// gateway. +func (client ConfigurationsClient) Get(resourceGroupName string, clusterName string, configurationName Configurationname) (result HTTPConnectivitySettings, err error) { + req, err := client.GetPreparer(resourceGroupName, clusterName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ConfigurationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationsClient) GetPreparer(resourceGroupName string, clusterName string, configurationName Configurationname) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) GetResponder(resp *http.Response) (result HTTPConnectivitySettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateHTTPSettings begins configuring the HTTP settings on the specified +// cluster. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. configurationName is the constant for configuration type of +// gateway. parameters is the name of the resource group. +func (client ConfigurationsClient) UpdateHTTPSettings(resourceGroupName string, clusterName string, configurationName string, parameters HTTPConnectivitySettings, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.UpdateHTTPSettingsPreparer(resourceGroupName, clusterName, configurationName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ConfigurationsClient", "UpdateHTTPSettings", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateHTTPSettingsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ConfigurationsClient", "UpdateHTTPSettings", resp, "Failure sending request") + return + } + + result, err = client.UpdateHTTPSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ConfigurationsClient", "UpdateHTTPSettings", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdateHTTPSettingsPreparer prepares the UpdateHTTPSettings request. +func (client ConfigurationsClient) UpdateHTTPSettingsPreparer(resourceGroupName string, clusterName string, configurationName string, parameters HTTPConnectivitySettings, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateHTTPSettingsSender sends the UpdateHTTPSettings request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) UpdateHTTPSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateHTTPSettingsResponder handles the response to the UpdateHTTPSettings request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) UpdateHTTPSettingsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/arm/hdinsight/extension.go b/arm/hdinsight/extension.go new file mode 100644 index 000000000000..348ef83683b1 --- /dev/null +++ b/arm/hdinsight/extension.go @@ -0,0 +1,243 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ExtensionClient is the the HDInsight Management Client. +type ExtensionClient struct { + ManagementClient +} + +// NewExtensionClient creates an instance of the ExtensionClient client. +func NewExtensionClient(subscriptionID string) ExtensionClient { + return NewExtensionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExtensionClientWithBaseURI creates an instance of the ExtensionClient +// client. +func NewExtensionClientWithBaseURI(baseURI string, subscriptionID string) ExtensionClient { + return ExtensionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create HDInsight cluster extension. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. parameters is the cluster extensions create request. +// extensionName is the name of the cluster extension. +func (client ExtensionClient) Create(resourceGroupName string, clusterName string, parameters Extension, extensionName string) (result autorest.Response, err error) { + req, err := client.CreatePreparer(resourceGroupName, clusterName, parameters, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ExtensionClient) CreatePreparer(resourceGroupName string, clusterName string, parameters Extension, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ExtensionClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ExtensionClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete delete extension for HDInsight cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. extensionName is the name of the cluster extension. +func (client ExtensionClient) Delete(resourceGroupName string, clusterName string, extensionName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, clusterName, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ExtensionClient) DeletePreparer(resourceGroupName string, clusterName string, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ExtensionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ExtensionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get extension properties for HDInsight cluster extension. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. extensionName is the name of the cluster extension. +func (client ExtensionClient) Get(resourceGroupName string, clusterName string, extensionName string) (result Extension, err error) { + req, err := client.GetPreparer(resourceGroupName, clusterName, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ExtensionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExtensionClient) GetPreparer(resourceGroupName string, clusterName string, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ExtensionClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExtensionClient) GetResponder(resp *http.Response) (result Extension, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/hdinsight/location.go b/arm/hdinsight/location.go new file mode 100644 index 000000000000..8a94df775b30 --- /dev/null +++ b/arm/hdinsight/location.go @@ -0,0 +1,105 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// LocationClient is the the HDInsight Management Client. +type LocationClient struct { + ManagementClient +} + +// NewLocationClient creates an instance of the LocationClient client. +func NewLocationClient(subscriptionID string) LocationClient { + return NewLocationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationClientWithBaseURI creates an instance of the LocationClient +// client. +func NewLocationClientWithBaseURI(baseURI string, subscriptionID string) LocationClient { + return LocationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetCapabilities gets the capabilities for the specified location. +// +// location is the location to get capabilities for. +func (client LocationClient) GetCapabilities(location string) (result CapabilitiesResult, err error) { + req, err := client.GetCapabilitiesPreparer(location) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.LocationClient", "GetCapabilities", nil, "Failure preparing request") + return + } + + resp, err := client.GetCapabilitiesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.LocationClient", "GetCapabilities", resp, "Failure sending request") + return + } + + result, err = client.GetCapabilitiesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.LocationClient", "GetCapabilities", resp, "Failure responding to request") + } + + return +} + +// GetCapabilitiesPreparer prepares the GetCapabilities request. +func (client LocationClient) GetCapabilitiesPreparer(location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetCapabilitiesSender sends the GetCapabilities request. The method will close the +// http.Response Body if it receives an error. +func (client LocationClient) GetCapabilitiesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetCapabilitiesResponder handles the response to the GetCapabilities request. The method always +// closes the http.Response Body. +func (client LocationClient) GetCapabilitiesResponder(resp *http.Response) (result CapabilitiesResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/hdinsight/models.go b/arm/hdinsight/models.go new file mode 100644 index 000000000000..a5c1d66f842f --- /dev/null +++ b/arm/hdinsight/models.go @@ -0,0 +1,602 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// AsyncOperationState enumerates the values for async operation state. +type AsyncOperationState string + +const ( + // Failed specifies the failed state for async operation state. + Failed AsyncOperationState = "Failed" + // InProgress specifies the in progress state for async operation state. + InProgress AsyncOperationState = "InProgress" + // Succeeded specifies the succeeded state for async operation state. + Succeeded AsyncOperationState = "Succeeded" +) + +// ClusterProvisioningState enumerates the values for cluster provisioning +// state. +type ClusterProvisioningState string + +const ( + // ClusterProvisioningStateCanceled specifies the cluster provisioning + // state canceled state for cluster provisioning state. + ClusterProvisioningStateCanceled ClusterProvisioningState = "Canceled" + // ClusterProvisioningStateDeleting specifies the cluster provisioning + // state deleting state for cluster provisioning state. + ClusterProvisioningStateDeleting ClusterProvisioningState = "Deleting" + // ClusterProvisioningStateFailed specifies the cluster provisioning state + // failed state for cluster provisioning state. + ClusterProvisioningStateFailed ClusterProvisioningState = "Failed" + // ClusterProvisioningStateInProgress specifies the cluster provisioning + // state in progress state for cluster provisioning state. + ClusterProvisioningStateInProgress ClusterProvisioningState = "InProgress" + // ClusterProvisioningStateSucceeded specifies the cluster provisioning + // state succeeded state for cluster provisioning state. + ClusterProvisioningStateSucceeded ClusterProvisioningState = "Succeeded" +) + +// Configurationname enumerates the values for configurationname. +type Configurationname string + +const ( + // CoreSite specifies the core site state for configurationname. + CoreSite Configurationname = "core-site" + // Gateway specifies the gateway state for configurationname. + Gateway Configurationname = "gateway" +) + +// DirectoryType enumerates the values for directory type. +type DirectoryType string + +const ( + // ActiveDirectory specifies the active directory state for directory type. + ActiveDirectory DirectoryType = "ActiveDirectory" +) + +// OSType enumerates the values for os type. +type OSType string + +const ( + // Linux specifies the linux state for os type. + Linux OSType = "Linux" + // Windows specifies the windows state for os type. + Windows OSType = "Windows" +) + +// Tier enumerates the values for tier. +type Tier string + +const ( + // Premium specifies the premium state for tier. + Premium Tier = "Premium" + // Standard specifies the standard state for tier. + Standard Tier = "Standard" +) + +// Application is hDInsight cluster application +type Application struct { + autorest.Response `json:"-"` + ID *SubResource `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Etag *string `json:"etag,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Properties *ApplicationGetProperties `json:"properties,omitempty"` +} + +// ApplicationGetEndpoint is gets Application ssh endpoint +type ApplicationGetEndpoint struct { + Location *string `json:"location,omitempty"` + DestinationPort *int32 `json:"destinationPort,omitempty"` + PublicPort *int32 `json:"publicPort,omitempty"` +} + +// ApplicationGetHTTPSEndpoint is gets application Http endpoints. +type ApplicationGetHTTPSEndpoint struct { + AdditionalProperties *map[string]*string `json:",omitempty"` + AccessModes *[]string `json:"accessModes,omitempty"` + Location *string `json:"location,omitempty"` + DestinationPort *int32 `json:"destinationPort,omitempty"` + PublicPort *int32 `json:"publicPort,omitempty"` +} + +// ApplicationGetProperties is hDInsight cluster application. +type ApplicationGetProperties struct { + ComputeProfile *ComputeProfile `json:"computeProfile,omitempty"` + InstallScriptActions *[]RuntimeScriptAction `json:"installScriptActions,omitempty"` + UninstallScriptActions *[]RuntimeScriptAction `json:"uninstallScriptActions,omitempty"` + HTTPSEndpoints *[]ApplicationGetHTTPSEndpoint `json:"httpsEndpoints,omitempty"` + SSHEndpoints *[]ApplicationGetEndpoint `json:"sshEndpoints,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ApplicationType *string `json:"applicationType,omitempty"` + ApplicationState *string `json:"applicationState,omitempty"` + Errors *[]Errors `json:"errors,omitempty"` + CreatedDate *string `json:"createdDate,omitempty"` + MarketplaceIdentifier *string `json:"marketplaceIdentifier,omitempty"` + AdditionalProperties *string `json:"additionalProperties,omitempty"` +} + +// ApplicationListResult is result of the request to list cluster Applications. +// It contains a list of operations and a URL link to get the next set of +// results. +type ApplicationListResult struct { + autorest.Response `json:"-"` + Value *[]Application `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplicationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ApplicationListResult) ApplicationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// CapabilitiesResult is the Get Capabilities operation response. +type CapabilitiesResult struct { + autorest.Response `json:"-"` + Versions *map[string]*VersionsCapability `json:"versions,omitempty"` + Regions *map[string]*RegionsCapability `json:"regions,omitempty"` + Vmsizes *map[string]*VMSizesCapability `json:"vmsizes,omitempty"` + VmsizeFilters *[]VMSizeCompatibilityFilter `json:"vmsize_filters,omitempty"` + Features *[]string `json:"features,omitempty"` + Quota *QuotaCapability `json:"quota,omitempty"` +} + +// Cluster is describes the cluster. +type Cluster struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Etag *string `json:"etag,omitempty"` + Properties *ClusterGetProperties `json:"properties,omitempty"` +} + +// ClusterCreateParametersExtended is the CreateCluster request parameters. +type ClusterCreateParametersExtended struct { + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + Properties *ClusterCreateProperties `json:"properties,omitempty"` +} + +// ClusterCreateProperties is the cluster create parameters. +type ClusterCreateProperties struct { + ClusterVersion *string `json:"clusterVersion,omitempty"` + OsType OSType `json:"osType,omitempty"` + Tier Tier `json:"tier,omitempty"` + ClusterDefinition *ClusterDefinition `json:"clusterDefinition,omitempty"` + SecurityProfile *SecurityProfile `json:"securityProfile,omitempty"` + ComputeProfile *ComputeProfile `json:"computeProfile,omitempty"` + StorageProfile *StorageProfile `json:"storageProfile,omitempty"` +} + +// ClusterDefinition is the cluste definition. +type ClusterDefinition struct { + Blueprint *string `json:"blueprint,omitempty"` + Kind *string `json:"kind,omitempty"` + ComponentVersion *map[string]*string `json:"componentVersion,omitempty"` + Configurations *map[string]interface{} `json:"configurations,omitempty"` +} + +// ClusterGetProperties is the properties of cluster. +type ClusterGetProperties struct { + ClusterVersion *string `json:"clusterVersion,omitempty"` + OsType OSType `json:"osType,omitempty"` + Tier Tier `json:"tier,omitempty"` + ClusterDefinition *ClusterDefinition `json:"clusterDefinition,omitempty"` + SecurityProfile *SecurityProfile `json:"securityProfile,omitempty"` + ComputeProfile *ComputeProfile `json:"computeProfile,omitempty"` + ProvisioningState ClusterProvisioningState `json:"provisioningState,omitempty"` + CreatedDate *string `json:"createdDate,omitempty"` + ClusterState *string `json:"clusterState,omitempty"` + QuotaInfo *QuotaInfo `json:"quotaInfo,omitempty"` + Errors *[]Errors `json:"errors,omitempty"` + ConnectivityEndpoints *[]ConnectivityEndpoint `json:"connectivityEndpoints,omitempty"` +} + +// ClusterListPersistedScriptActionsResult is list PersistedScriptActions +// operations response. +type ClusterListPersistedScriptActionsResult struct { + Value *[]RuntimeScriptAction `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterListResult is the List Cluster operation response. +type ClusterListResult struct { + autorest.Response `json:"-"` + Value *[]Cluster `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ClusterListResult) ClusterListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ClusterListRuntimeScriptActionDetailResult is the ListScriptExecutionHistory +// response. +type ClusterListRuntimeScriptActionDetailResult struct { + Value *[]RuntimeScriptActionDetail `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterPatchParameters is the PatchCluster request parameters +type ClusterPatchParameters struct { + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ClusterResizeParameters is the Resize Cluster request parameters. +type ClusterResizeParameters struct { + TargetInstanceCount *int32 `json:"targetInstanceCount,omitempty"` +} + +// ComputeProfile is describes the compute profile. +type ComputeProfile struct { + Roles *[]Role `json:"roles,omitempty"` +} + +// ConnectivityEndpoint is the connectivity properties +type ConnectivityEndpoint struct { + Name *string `json:"name,omitempty"` + Protocol *string `json:"protocol,omitempty"` + Location *string `json:"location,omitempty"` + Port *int32 `json:"port,omitempty"` +} + +// Errors is the error message associated with the cluster creation. +type Errors struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ExecuteScriptActionParameters is describes the script actions on a running +// cluster. +type ExecuteScriptActionParameters struct { + ScriptActions *[]RuntimeScriptAction `json:"scriptActions,omitempty"` + PersistOnSuccess *string `json:"persistOnSuccess,omitempty"` +} + +// Extension is cluster monitoring extensions +type Extension struct { + autorest.Response `json:"-"` + WorkspaceID *string `json:"workspaceId,omitempty"` + PrimaryKey *string `json:"primaryKey,omitempty"` +} + +// HardwareProfile is describes the hardware profile. +type HardwareProfile struct { + VMSize *string `json:"vmSize,omitempty"` +} + +// HTTPConnectivitySettings is the payload for a Configure HTTP settings +// request. +type HTTPConnectivitySettings struct { + autorest.Response `json:"-"` + EnabledCredential *string `json:"restAuthCredential.isEnabled,omitempty"` + Username *string `json:"restAuthCredential.username,omitempty"` + Password *string `json:"restAuthCredential.password,omitempty"` +} + +// HTTPSettingsParameters is the payload for a Configure HTTP settings request. +type HTTPSettingsParameters struct { + RestAuthCredentialisEnabled *string `json:"restAuthCredential.isEnabled,omitempty"` + RestAuthCredentialusername *string `json:"restAuthCredential.username,omitempty"` + RestAuthCredentialpassword *string `json:"restAuthCredential.password,omitempty"` +} + +// LinuxOperatingSystemProfile is the ssh username, password, and ssh public +// key. +type LinuxOperatingSystemProfile struct { + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + SSHProfile *SSHProfile `json:"sshProfile,omitempty"` +} + +// Operation is hDInsight REST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is the object that represents the operation. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult is result of the request to list HDInsight operations. +// It contains a list of operations and a URL link to get the next set of +// results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// OperationResource is the azure async operation response. +type OperationResource struct { + Status AsyncOperationState `json:"status,omitempty"` + Error *Errors `json:"error,omitempty"` +} + +// OsProfile is the Windows operation systems profile, and configure remote +// desktop settings. +type OsProfile struct { + WindowsOperatingSystemProfile *WindowsOperatingSystemProfile `json:"windowsOperatingSystemProfile,omitempty"` + LinuxOperatingSystemProfile *LinuxOperatingSystemProfile `json:"linuxOperatingSystemProfile,omitempty"` +} + +// QuotaCapability is the regional quota capability. +type QuotaCapability struct { + RegionalQuotas *[]RegionalQuotaCapability `json:"regionalQuotas,omitempty"` +} + +// QuotaInfo is gets or sets Quota properties for the cluster. +type QuotaInfo struct { + CoresUsed *int32 `json:"coresUsed,omitempty"` +} + +// RdpSettings is the RDP settings for the windows cluster. +type RdpSettings struct { + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + ExpiryDate *date.Date `json:"expiryDate,omitempty"` +} + +// RDPSettingsParameters is parameters specifying the data factory gateway +// definition for a create or update operation. +type RDPSettingsParameters struct { + OsProfile *OsProfile `json:"osProfile,omitempty"` +} + +// RegionalQuotaCapability is the regional quota capacity. +type RegionalQuotaCapability struct { + RegionName *string `json:"region_name,omitempty"` + CoresUsed *int64 `json:"cores_used,omitempty"` + CoresAvailable *int64 `json:"cores_available,omitempty"` +} + +// RegionsCapability is the regions capability. +type RegionsCapability struct { + Available *[]string `json:"available,omitempty"` +} + +// Resource is the resource definition. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// Role is describes a role on the cluster. +type Role struct { + Name *string `json:"name,omitempty"` + MinInstanceCount *int32 `json:"minInstanceCount,omitempty"` + TargetInstanceCount *int32 `json:"targetInstanceCount,omitempty"` + HardwareProfile *HardwareProfile `json:"hardwareProfile,omitempty"` + OsProfile *OsProfile `json:"osProfile,omitempty"` + VirtualNetworkProfile *VirtualNetworkProfile `json:"virtualNetworkProfile,omitempty"` + ScriptActions *[]ScriptAction `json:"scriptActions,omitempty"` +} + +// RuntimeScriptAction is describes a script action on a running cluster. +type RuntimeScriptAction struct { + Name *string `json:"name,omitempty"` + URI *string `json:"uri,omitempty"` + Parameters *string `json:"parameters,omitempty"` + Roles *[]string `json:"roles,omitempty"` + ApplicationName *string `json:"applicationName,omitempty"` +} + +// RuntimeScriptActionDetail is describes the execution details of a script +// action. +type RuntimeScriptActionDetail struct { + autorest.Response `json:"-"` + ScriptExecutionID *int64 `json:"scriptExecutionId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Status *string `json:"status,omitempty"` + Operation *string `json:"operation,omitempty"` + ExecutionSummary *[]ScriptActionExecutionSummary `json:"executionSummary,omitempty"` + DebugInformation *string `json:"debugInformation,omitempty"` + Name *string `json:"name,omitempty"` + URI *string `json:"uri,omitempty"` + Parameters *string `json:"parameters,omitempty"` + Roles *[]string `json:"roles,omitempty"` + ApplicationName *string `json:"applicationName,omitempty"` +} + +// ScriptAction is describes a script action on role on the cluster. +type ScriptAction struct { + Name *string `json:"name,omitempty"` + URI *string `json:"uri,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} + +// ScriptActionExecutionHistoryList is the ListScriptExecutionHistory response. +type ScriptActionExecutionHistoryList struct { + autorest.Response `json:"-"` + Value *[]RuntimeScriptActionDetail `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ScriptActionExecutionHistoryListPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ScriptActionExecutionHistoryList) ScriptActionExecutionHistoryListPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ScriptActionExecutionSummary is describes the execution summary of a script +// action. +type ScriptActionExecutionSummary struct { + Status *string `json:"status,omitempty"` + InstanceCount *int32 `json:"instanceCount,omitempty"` +} + +// ScriptActionPersistedGetResponseSpec is the persisted script action for +// cluster +type ScriptActionPersistedGetResponseSpec struct { + Name *string `json:"name,omitempty"` + URI *string `json:"uri,omitempty"` + Parameters *string `json:"parameters,omitempty"` + Roles *[]string `json:"roles,omitempty"` + ApplicationName *string `json:"applicationName,omitempty"` +} + +// ScriptActionsList is all persisted script action for the cluster. +type ScriptActionsList struct { + autorest.Response `json:"-"` + Value *[]RuntimeScriptActionDetail `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ScriptActionsListPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ScriptActionsList) ScriptActionsListPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// SecurityProfile is the security profile which contains Ssh public key for +// the HDInsight cluster. +type SecurityProfile struct { + DirectoryType DirectoryType `json:"directoryType,omitempty"` + Domain *string `json:"domain,omitempty"` + OrganizationalUnitDN *string `json:"organizationalUnitDN,omitempty"` + LdapsUrls *[]string `json:"ldapsUrls,omitempty"` + DomainUsername *string `json:"domainUsername,omitempty"` + DomainUserPassword *string `json:"domainUserPassword,omitempty"` + ClusterUsersGroupDNs *[]string `json:"clusterUsersGroupDNs,omitempty"` +} + +// SSHProfile is the list of Ssh public keys. +type SSHProfile struct { + PublicKeys *[]SSHPublicKey `json:"publicKeys,omitempty"` +} + +// SSHPublicKey is the Ssh public key for the cluster nodes. +type SSHPublicKey struct { + CertificateData *string `json:"certificateData,omitempty"` +} + +// StorageAccount is describes the storage Account. +type StorageAccount struct { + Name *string `json:"name,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Container *string `json:"container,omitempty"` + Key *string `json:"key,omitempty"` +} + +// StorageProfile is describes the storage profile. +type StorageProfile struct { + Storageaccounts *[]StorageAccount `json:"storageaccounts,omitempty"` +} + +// SubResource is the sub resource definition. +type SubResource struct { + ID *string `json:"id,omitempty"` +} + +// VersionsCapability is the version capability. +type VersionsCapability struct { + Available *[]VersionSpec `json:"available,omitempty"` +} + +// VersionSpec is gets or sets Version spec properties. +type VersionSpec struct { + FriendlyName *string `json:"friendlyName,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsDefault *string `json:"isDefault,omitempty"` + ComponentVersions *map[string]*string `json:"componentVersions,omitempty"` +} + +// VirtualNetworkProfile is the Virtual network properties. +type VirtualNetworkProfile struct { + ID *string `json:"id,omitempty"` + Subnet *string `json:"subnet,omitempty"` +} + +// VMSizeCompatibilityFilter is the virtual machine type compatibility filter. +type VMSizeCompatibilityFilter struct { + FilterMode *string `json:"FilterMode,omitempty"` + Regions *[]string `json:"Regions,omitempty"` + ClusterFlavors *[]string `json:"ClusterFlavors,omitempty"` + NodeTypes *[]string `json:"NodeTypes,omitempty"` + ClusterVersions *[]string `json:"ClusterVersions,omitempty"` + Vmsizes *[]string `json:"vmsizes,omitempty"` +} + +// VMSizesCapability is the virtual machine sizes capability. +type VMSizesCapability struct { + Available *[]string `json:"available,omitempty"` +} + +// WindowsOperatingSystemProfile is the Windows operation system settings. +type WindowsOperatingSystemProfile struct { + RdpSettings *RdpSettings `json:"rdpSettings,omitempty"` +} diff --git a/arm/hdinsight/operations.go b/arm/hdinsight/operations.go new file mode 100644 index 000000000000..ee3e33792a56 --- /dev/null +++ b/arm/hdinsight/operations.go @@ -0,0 +1,122 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the the HDInsight Management Client. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available HDInsight REST API operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.HDInsight/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "hdinsight.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hdinsight.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/hdinsight/scriptactions.go b/arm/hdinsight/scriptactions.go new file mode 100644 index 000000000000..9b5917edfa0d --- /dev/null +++ b/arm/hdinsight/scriptactions.go @@ -0,0 +1,198 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ScriptActionsClient is the the HDInsight Management Client. +type ScriptActionsClient struct { + ManagementClient +} + +// NewScriptActionsClient creates an instance of the ScriptActionsClient +// client. +func NewScriptActionsClient(subscriptionID string) ScriptActionsClient { + return NewScriptActionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScriptActionsClientWithBaseURI creates an instance of the +// ScriptActionsClient client. +func NewScriptActionsClientWithBaseURI(baseURI string, subscriptionID string) ScriptActionsClient { + return ScriptActionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a given persisted script action of the cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. scriptName is the name of the script. +func (client ScriptActionsClient) Delete(resourceGroupName string, clusterName string, scriptName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, clusterName, scriptName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScriptActionsClient) DeletePreparer(resourceGroupName string, clusterName string, scriptName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptName": autorest.Encode("path", scriptName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions/{scriptName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ScriptActionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScriptActionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// List lists all persisted script actions for the given cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. +func (client ScriptActionsClient) List(resourceGroupName string, clusterName string) (result ScriptActionsList, err error) { + req, err := client.ListPreparer(resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ScriptActionsClient) ListPreparer(resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ScriptActionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ScriptActionsClient) ListResponder(resp *http.Response) (result ScriptActionsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ScriptActionsClient) ListNextResults(lastResults ScriptActionsList) (result ScriptActionsList, err error) { + req, err := lastResults.ScriptActionsListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptActionsClient", "List", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/hdinsight/scriptexecutionhistory.go b/arm/hdinsight/scriptexecutionhistory.go new file mode 100644 index 000000000000..dd06c170c6e6 --- /dev/null +++ b/arm/hdinsight/scriptexecutionhistory.go @@ -0,0 +1,265 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ScriptExecutionHistoryClient is the the HDInsight Management Client. +type ScriptExecutionHistoryClient struct { + ManagementClient +} + +// NewScriptExecutionHistoryClient creates an instance of the +// ScriptExecutionHistoryClient client. +func NewScriptExecutionHistoryClient(subscriptionID string) ScriptExecutionHistoryClient { + return NewScriptExecutionHistoryClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScriptExecutionHistoryClientWithBaseURI creates an instance of the +// ScriptExecutionHistoryClient client. +func NewScriptExecutionHistoryClientWithBaseURI(baseURI string, subscriptionID string) ScriptExecutionHistoryClient { + return ScriptExecutionHistoryClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the script execution detail for the given script execution id. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. scriptExecutionID is the script execution Id +func (client ScriptExecutionHistoryClient) Get(resourceGroupName string, clusterName string, scriptExecutionID string) (result RuntimeScriptActionDetail, err error) { + req, err := client.GetPreparer(resourceGroupName, clusterName, scriptExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScriptExecutionHistoryClient) GetPreparer(resourceGroupName string, clusterName string, scriptExecutionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptExecutionId": autorest.Encode("path", scriptExecutionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ScriptExecutionHistoryClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScriptExecutionHistoryClient) GetResponder(resp *http.Response) (result RuntimeScriptActionDetail, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all scripts execution history for the given cluster. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. +func (client ScriptExecutionHistoryClient) List(resourceGroupName string, clusterName string) (result ScriptActionExecutionHistoryList, err error) { + req, err := client.ListPreparer(resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ScriptExecutionHistoryClient) ListPreparer(resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ScriptExecutionHistoryClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ScriptExecutionHistoryClient) ListResponder(resp *http.Response) (result ScriptActionExecutionHistoryList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ScriptExecutionHistoryClient) ListNextResults(lastResults ScriptActionExecutionHistoryList) (result ScriptActionExecutionHistoryList, err error) { + req, err := lastResults.ScriptActionExecutionHistoryListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// Promote promote ad-hoc script execution to a persisted script. +// +// resourceGroupName is the name of the resource group. clusterName is the name +// of the cluster. scriptExecutionID is the script execution Id +func (client ScriptExecutionHistoryClient) Promote(resourceGroupName string, clusterName string, scriptExecutionID int64) (result autorest.Response, err error) { + req, err := client.PromotePreparer(resourceGroupName, clusterName, scriptExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "Promote", nil, "Failure preparing request") + return + } + + resp, err := client.PromoteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "Promote", resp, "Failure sending request") + return + } + + result, err = client.PromoteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hdinsight.ScriptExecutionHistoryClient", "Promote", resp, "Failure responding to request") + } + + return +} + +// PromotePreparer prepares the Promote request. +func (client ScriptExecutionHistoryClient) PromotePreparer(resourceGroupName string, clusterName string, scriptExecutionID int64) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scriptExecutionId": autorest.Encode("path", scriptExecutionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}/promote", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// PromoteSender sends the Promote request. The method will close the +// http.Response Body if it receives an error. +func (client ScriptExecutionHistoryClient) PromoteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// PromoteResponder handles the response to the Promote request. The method always +// closes the http.Response Body. +func (client ScriptExecutionHistoryClient) PromoteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/arm/hdinsight/version.go b/arm/hdinsight/version.go new file mode 100644 index 000000000000..2c75e700f514 --- /dev/null +++ b/arm/hdinsight/version.go @@ -0,0 +1,29 @@ +package hdinsight + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.0.0-beta arm-hdinsight/" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.0.0-beta" +} diff --git a/arm/insights/alertruleincidents.go b/arm/insights/alertruleincidents.go new file mode 100644 index 000000000000..5be1fc5e8053 --- /dev/null +++ b/arm/insights/alertruleincidents.go @@ -0,0 +1,176 @@ +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// AlertRuleIncidentsClient is the composite Swagger for Insights Management +// Client +type AlertRuleIncidentsClient struct { + ManagementClient +} + +// NewAlertRuleIncidentsClient creates an instance of the +// AlertRuleIncidentsClient client. +func NewAlertRuleIncidentsClient(subscriptionID string) AlertRuleIncidentsClient { + return NewAlertRuleIncidentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRuleIncidentsClientWithBaseURI creates an instance of the +// AlertRuleIncidentsClient client. +func NewAlertRuleIncidentsClientWithBaseURI(baseURI string, subscriptionID string) AlertRuleIncidentsClient { + return AlertRuleIncidentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets an incident associated to an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of +// the rule. incidentName is the name of the incident to retrieve. +func (client AlertRuleIncidentsClient) Get(resourceGroupName string, ruleName string, incidentName string) (result Incident, err error) { + req, err := client.GetPreparer(resourceGroupName, ruleName, incidentName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRuleIncidentsClient) GetPreparer(resourceGroupName string, ruleName string, incidentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "incidentName": autorest.Encode("path", incidentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRuleIncidentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) GetResponder(resp *http.Response) (result Incident, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAlertRule gets a list of incidents associated to an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of +// the rule. +func (client AlertRuleIncidentsClient) ListByAlertRule(resourceGroupName string, ruleName string) (result IncidentListResult, err error) { + req, err := client.ListByAlertRulePreparer(resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAlertRuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure sending request") + return + } + + result, err = client.ListByAlertRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure responding to request") + } + + return +} + +// ListByAlertRulePreparer prepares the ListByAlertRule request. +func (client AlertRuleIncidentsClient) ListByAlertRulePreparer(resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByAlertRuleSender sends the ListByAlertRule request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRuleIncidentsClient) ListByAlertRuleSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByAlertRuleResponder handles the response to the ListByAlertRule request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) ListByAlertRuleResponder(resp *http.Response) (result IncidentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/insights/alertrules.go b/arm/insights/alertrules.go new file mode 100644 index 000000000000..1e3e5f28387e --- /dev/null +++ b/arm/insights/alertrules.go @@ -0,0 +1,321 @@ +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AlertRulesClient is the composite Swagger for Insights Management Client +type AlertRulesClient struct { + ManagementClient +} + +// NewAlertRulesClient creates an instance of the AlertRulesClient client. +func NewAlertRulesClient(subscriptionID string) AlertRulesClient { + return NewAlertRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRulesClientWithBaseURI creates an instance of the AlertRulesClient +// client. +func NewAlertRulesClientWithBaseURI(baseURI string, subscriptionID string) AlertRulesClient { + return AlertRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an alert rule. +// Request method: PUT Request URI: +// https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/microsoft.insights/alertRules/{alert-rule-name}?api-version={api-version} +// +// resourceGroupName is the name of the resource group. ruleName is the name of +// the rule. parameters is the parameters of the rule to create or update. +func (client AlertRulesClient) CreateOrUpdate(resourceGroupName string, ruleName string, parameters AlertRuleResource) (result AlertRuleResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AlertRule", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AlertRule.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AlertRule.IsEnabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.AlertRulesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AlertRulesClient) CreateOrUpdatePreparer(resourceGroupName string, ruleName string, parameters AlertRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) CreateOrUpdateResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of +// the rule. +func (client AlertRulesClient) Delete(resourceGroupName string, ruleName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AlertRulesClient) DeletePreparer(resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an alert rule +// +// resourceGroupName is the name of the resource group. ruleName is the name of +// the rule. +func (client AlertRulesClient) Get(resourceGroupName string, ruleName string) (result AlertRuleResource, err error) { + req, err := client.GetPreparer(resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRulesClient) GetPreparer(resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) GetResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list the alert rules within a resource group. +// +// resourceGroupName is the name of the resource group. filter is the filter to +// apply on the operation. For more information please see +// https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx +func (client AlertRulesClient) ListByResourceGroup(resourceGroupName string, filter string) (result AlertRuleResourceCollection, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AlertRulesClient) ListByResourceGroupPreparer(resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) ListByResourceGroupResponder(resp *http.Response) (result AlertRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/insights/autoscalesettings.go b/arm/insights/autoscalesettings.go new file mode 100644 index 000000000000..f25b210700ec --- /dev/null +++ b/arm/insights/autoscalesettings.go @@ -0,0 +1,347 @@ +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AutoscaleSettingsClient is the composite Swagger for Insights Management +// Client +type AutoscaleSettingsClient struct { + ManagementClient +} + +// NewAutoscaleSettingsClient creates an instance of the +// AutoscaleSettingsClient client. +func NewAutoscaleSettingsClient(subscriptionID string) AutoscaleSettingsClient { + return NewAutoscaleSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAutoscaleSettingsClientWithBaseURI creates an instance of the +// AutoscaleSettingsClient client. +func NewAutoscaleSettingsClientWithBaseURI(baseURI string, subscriptionID string) AutoscaleSettingsClient { + return AutoscaleSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an autoscale setting. +// +// resourceGroupName is the name of the resource group. autoscaleSettingName is +// the autoscale setting name. parameters is parameters supplied to the +// operation. +func (client AutoscaleSettingsClient) CreateOrUpdate(resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (result AutoscaleSettingResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AutoscaleSetting", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.MaxItems, Rule: 20, Chain: nil}}}, + {Target: "parameters.AutoscaleSetting.Name", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, autoscaleSettingName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AutoscaleSettingsClient) CreateOrUpdatePreparer(resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes and autoscale setting +// +// resourceGroupName is the name of the resource group. autoscaleSettingName is +// the autoscale setting name. +func (client AutoscaleSettingsClient) Delete(resourceGroupName string, autoscaleSettingName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AutoscaleSettingsClient) DeletePreparer(resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an autoscale setting +// +// resourceGroupName is the name of the resource group. autoscaleSettingName is +// the autoscale setting name. +func (client AutoscaleSettingsClient) Get(resourceGroupName string, autoscaleSettingName string) (result AutoscaleSettingResource, err error) { + req, err := client.GetPreparer(resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AutoscaleSettingsClient) GetPreparer(resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) GetResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists the autoscale settings for a resource group +// +// resourceGroupName is the name of the resource group. filter is the filter to +// apply on the operation. For more information please see +// https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx +func (client AutoscaleSettingsClient) ListByResourceGroup(resourceGroupName string, filter string) (result AutoscaleSettingResourceCollection, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AutoscaleSettingsClient) ListByResourceGroupPreparer(resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) ListByResourceGroupResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client AutoscaleSettingsClient) ListByResourceGroupNextResults(lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) { + req, err := lastResults.AutoscaleSettingResourceCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} diff --git a/arm/insights/client.go b/arm/insights/client.go new file mode 100644 index 000000000000..1543209fb4ca --- /dev/null +++ b/arm/insights/client.go @@ -0,0 +1,52 @@ +// Package insights implements the Azure ARM Insights service API version . +// +// Composite Swagger for Insights Management Client +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Insights + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Insights. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/arm/insights/logprofiles.go b/arm/insights/logprofiles.go new file mode 100644 index 000000000000..e17e1d470dfe --- /dev/null +++ b/arm/insights/logprofiles.go @@ -0,0 +1,309 @@ +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// LogProfilesClient is the composite Swagger for Insights Management Client +type LogProfilesClient struct { + ManagementClient +} + +// NewLogProfilesClient creates an instance of the LogProfilesClient client. +func NewLogProfilesClient(subscriptionID string) LogProfilesClient { + return NewLogProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLogProfilesClientWithBaseURI creates an instance of the LogProfilesClient +// client. +func NewLogProfilesClientWithBaseURI(baseURI string, subscriptionID string) LogProfilesClient { + return LogProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a log profile in Azure Monitoring REST API. +// +// logProfileName is the name of the log profile. parameters is parameters +// supplied to the operation. +func (client LogProfilesClient) CreateOrUpdate(logProfileName string, parameters LogProfileResource) (result LogProfileResource, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LogProfileProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "insights.LogProfilesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(logProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LogProfilesClient) CreateOrUpdatePreparer(logProfileName string, parameters LogProfileResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the log profile. +// +// logProfileName is the name of the log profile. +func (client LogProfilesClient) Delete(logProfileName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LogProfilesClient) DeletePreparer(logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the log profile. +// +// logProfileName is the name of the log profile. +func (client LogProfilesClient) Get(logProfileName string) (result LogProfileResource, err error) { + req, err := client.GetPreparer(logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LogProfilesClient) GetPreparer(logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) GetResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list the log profiles. +func (client LogProfilesClient) List() (result LogProfileCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client LogProfilesClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) ListResponder(resp *http.Response) (result LogProfileCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/insights/models.go b/arm/insights/models.go new file mode 100644 index 000000000000..06690e29abe7 --- /dev/null +++ b/arm/insights/models.go @@ -0,0 +1,511 @@ +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// ComparisonOperationType enumerates the values for comparison operation type. +type ComparisonOperationType string + +const ( + // Equals specifies the equals state for comparison operation type. + Equals ComparisonOperationType = "Equals" + // GreaterThan specifies the greater than state for comparison operation + // type. + GreaterThan ComparisonOperationType = "GreaterThan" + // GreaterThanOrEqual specifies the greater than or equal state for + // comparison operation type. + GreaterThanOrEqual ComparisonOperationType = "GreaterThanOrEqual" + // LessThan specifies the less than state for comparison operation type. + LessThan ComparisonOperationType = "LessThan" + // LessThanOrEqual specifies the less than or equal state for comparison + // operation type. + LessThanOrEqual ComparisonOperationType = "LessThanOrEqual" + // NotEquals specifies the not equals state for comparison operation type. + NotEquals ComparisonOperationType = "NotEquals" +) + +// ConditionOperator enumerates the values for condition operator. +type ConditionOperator string + +const ( + // ConditionOperatorGreaterThan specifies the condition operator greater + // than state for condition operator. + ConditionOperatorGreaterThan ConditionOperator = "GreaterThan" + // ConditionOperatorGreaterThanOrEqual specifies the condition operator + // greater than or equal state for condition operator. + ConditionOperatorGreaterThanOrEqual ConditionOperator = "GreaterThanOrEqual" + // ConditionOperatorLessThan specifies the condition operator less than + // state for condition operator. + ConditionOperatorLessThan ConditionOperator = "LessThan" + // ConditionOperatorLessThanOrEqual specifies the condition operator less + // than or equal state for condition operator. + ConditionOperatorLessThanOrEqual ConditionOperator = "LessThanOrEqual" +) + +// MetricStatisticType enumerates the values for metric statistic type. +type MetricStatisticType string + +const ( + // Average specifies the average state for metric statistic type. + Average MetricStatisticType = "Average" + // Max specifies the max state for metric statistic type. + Max MetricStatisticType = "Max" + // Min specifies the min state for metric statistic type. + Min MetricStatisticType = "Min" + // Sum specifies the sum state for metric statistic type. + Sum MetricStatisticType = "Sum" +) + +// RecurrenceFrequency enumerates the values for recurrence frequency. +type RecurrenceFrequency string + +const ( + // Day specifies the day state for recurrence frequency. + Day RecurrenceFrequency = "Day" + // Hour specifies the hour state for recurrence frequency. + Hour RecurrenceFrequency = "Hour" + // Minute specifies the minute state for recurrence frequency. + Minute RecurrenceFrequency = "Minute" + // Month specifies the month state for recurrence frequency. + Month RecurrenceFrequency = "Month" + // None specifies the none state for recurrence frequency. + None RecurrenceFrequency = "None" + // Second specifies the second state for recurrence frequency. + Second RecurrenceFrequency = "Second" + // Week specifies the week state for recurrence frequency. + Week RecurrenceFrequency = "Week" + // Year specifies the year state for recurrence frequency. + Year RecurrenceFrequency = "Year" +) + +// ScaleDirection enumerates the values for scale direction. +type ScaleDirection string + +const ( + // ScaleDirectionDecrease specifies the scale direction decrease state for + // scale direction. + ScaleDirectionDecrease ScaleDirection = "Decrease" + // ScaleDirectionIncrease specifies the scale direction increase state for + // scale direction. + ScaleDirectionIncrease ScaleDirection = "Increase" + // ScaleDirectionNone specifies the scale direction none state for scale + // direction. + ScaleDirectionNone ScaleDirection = "None" +) + +// ScaleType enumerates the values for scale type. +type ScaleType string + +const ( + // ChangeCount specifies the change count state for scale type. + ChangeCount ScaleType = "ChangeCount" + // ExactCount specifies the exact count state for scale type. + ExactCount ScaleType = "ExactCount" + // PercentChangeCount specifies the percent change count state for scale + // type. + PercentChangeCount ScaleType = "PercentChangeCount" +) + +// TimeAggregationOperator enumerates the values for time aggregation operator. +type TimeAggregationOperator string + +const ( + // TimeAggregationOperatorAverage specifies the time aggregation operator + // average state for time aggregation operator. + TimeAggregationOperatorAverage TimeAggregationOperator = "Average" + // TimeAggregationOperatorLast specifies the time aggregation operator last + // state for time aggregation operator. + TimeAggregationOperatorLast TimeAggregationOperator = "Last" + // TimeAggregationOperatorMaximum specifies the time aggregation operator + // maximum state for time aggregation operator. + TimeAggregationOperatorMaximum TimeAggregationOperator = "Maximum" + // TimeAggregationOperatorMinimum specifies the time aggregation operator + // minimum state for time aggregation operator. + TimeAggregationOperatorMinimum TimeAggregationOperator = "Minimum" + // TimeAggregationOperatorTotal specifies the time aggregation operator + // total state for time aggregation operator. + TimeAggregationOperatorTotal TimeAggregationOperator = "Total" +) + +// TimeAggregationType enumerates the values for time aggregation type. +type TimeAggregationType string + +const ( + // TimeAggregationTypeAverage specifies the time aggregation type average + // state for time aggregation type. + TimeAggregationTypeAverage TimeAggregationType = "Average" + // TimeAggregationTypeCount specifies the time aggregation type count state + // for time aggregation type. + TimeAggregationTypeCount TimeAggregationType = "Count" + // TimeAggregationTypeMaximum specifies the time aggregation type maximum + // state for time aggregation type. + TimeAggregationTypeMaximum TimeAggregationType = "Maximum" + // TimeAggregationTypeMinimum specifies the time aggregation type minimum + // state for time aggregation type. + TimeAggregationTypeMinimum TimeAggregationType = "Minimum" + // TimeAggregationTypeTotal specifies the time aggregation type total state + // for time aggregation type. + TimeAggregationTypeTotal TimeAggregationType = "Total" +) + +// AlertRule is an alert rule. +type AlertRule struct { + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Condition *RuleCondition `json:"condition,omitempty"` + Actions *[]RuleAction `json:"actions,omitempty"` + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` +} + +// AlertRuleResource is the alert rule resource. +type AlertRuleResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *AlertRule `json:"properties,omitempty"` +} + +// AlertRuleResourceCollection is represents a collection of alert rule +// resources. +type AlertRuleResourceCollection struct { + autorest.Response `json:"-"` + Value *[]AlertRuleResource `json:"value,omitempty"` +} + +// AutoscaleNotification is autoscale notification. +type AutoscaleNotification struct { + Operation *string `json:"operation,omitempty"` + Email *EmailNotification `json:"email,omitempty"` + Webhooks *[]WebhookNotification `json:"webhooks,omitempty"` +} + +// AutoscaleProfile is autoscale profile. +type AutoscaleProfile struct { + Name *string `json:"name,omitempty"` + Capacity *ScaleCapacity `json:"capacity,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` + FixedDate *TimeWindow `json:"fixedDate,omitempty"` + Recurrence *Recurrence `json:"recurrence,omitempty"` +} + +// AutoscaleSetting is a setting that contains all of the configuration for the +// automatic scaling of a resource. +type AutoscaleSetting struct { + Profiles *[]AutoscaleProfile `json:"profiles,omitempty"` + Notifications *[]AutoscaleNotification `json:"notifications,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` + TargetResourceURI *string `json:"targetResourceUri,omitempty"` +} + +// AutoscaleSettingResource is the autoscale setting resource. +type AutoscaleSettingResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *AutoscaleSetting `json:"properties,omitempty"` +} + +// AutoscaleSettingResourceCollection is represents a collection of autoscale +// setting resources. +type AutoscaleSettingResourceCollection struct { + autorest.Response `json:"-"` + Value *[]AutoscaleSettingResource `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// AutoscaleSettingResourceCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client AutoscaleSettingResourceCollection) AutoscaleSettingResourceCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// EmailNotification is email notification of an autoscale event. +type EmailNotification struct { + SendToSubscriptionAdministrator *bool `json:"sendToSubscriptionAdministrator,omitempty"` + SendToSubscriptionCoAdministrators *bool `json:"sendToSubscriptionCoAdministrators,omitempty"` + CustomEmails *[]string `json:"customEmails,omitempty"` +} + +// Incident is an alert incident indicates the activation status of an alert +// rule. +type Incident struct { + autorest.Response `json:"-"` + Name *string `json:"name,omitempty"` + RuleName *string `json:"ruleName,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + ActivatedTime *date.Time `json:"activatedTime,omitempty"` + ResolvedTime *date.Time `json:"resolvedTime,omitempty"` +} + +// IncidentListResult is the List incidents operation response. +type IncidentListResult struct { + autorest.Response `json:"-"` + Value *[]Incident `json:"value,omitempty"` +} + +// LocationThresholdRuleCondition is a rule condition based on a certain number +// of locations failing. +type LocationThresholdRuleCondition struct { + DataSource *RuleDataSource `json:"dataSource,omitempty"` + WindowSize *string `json:"windowSize,omitempty"` + FailedLocationCount *int32 `json:"failedLocationCount,omitempty"` +} + +// LogProfileCollection is represents a collection of log profiles. +type LogProfileCollection struct { + autorest.Response `json:"-"` + Value *[]LogProfileResource `json:"value,omitempty"` +} + +// LogProfileProperties is the log profile properties. +type LogProfileProperties struct { + StorageAccountID *string `json:"storageAccountId,omitempty"` + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Categories *[]string `json:"categories,omitempty"` + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// LogProfileResource is the log profile resource. +type LogProfileResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *LogProfileProperties `json:"properties,omitempty"` +} + +// LogSettings is part of MultiTenantDiagnosticSettings. Specifies the settings +// for a particular log. +type LogSettings struct { + Category *string `json:"category,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// ManagementEventAggregationCondition is how the data that is collected should +// be combined over time. +type ManagementEventAggregationCondition struct { + Operator ConditionOperator `json:"operator,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` + WindowSize *string `json:"windowSize,omitempty"` +} + +// ManagementEventRuleCondition is a management event rule condition. +type ManagementEventRuleCondition struct { + DataSource *RuleDataSource `json:"dataSource,omitempty"` + Aggregation *ManagementEventAggregationCondition `json:"aggregation,omitempty"` +} + +// MetricSettings is part of MultiTenantDiagnosticSettings. Specifies the +// settings for a particular metric. +type MetricSettings struct { + TimeGrain *string `json:"timeGrain,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// MetricTrigger is the trigger that results in a scaling action. +type MetricTrigger struct { + MetricName *string `json:"metricName,omitempty"` + MetricResourceURI *string `json:"metricResourceUri,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Statistic MetricStatisticType `json:"statistic,omitempty"` + TimeWindow *string `json:"timeWindow,omitempty"` + TimeAggregation TimeAggregationType `json:"timeAggregation,omitempty"` + Operator ComparisonOperationType `json:"operator,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` +} + +// Recurrence is the repeating times at which this profile begins. This element +// is not used if the FixedDate element is used. +type Recurrence struct { + Frequency RecurrenceFrequency `json:"frequency,omitempty"` + Schedule *RecurrentSchedule `json:"schedule,omitempty"` +} + +// RecurrentSchedule is the scheduling constraints for when the profile begins. +type RecurrentSchedule struct { + TimeZone *string `json:"timeZone,omitempty"` + Days *[]string `json:"days,omitempty"` + Hours *[]int32 `json:"hours,omitempty"` + Minutes *[]int32 `json:"minutes,omitempty"` +} + +// Resource is an azure resource object +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// RetentionPolicy is specifies the retention policy for the log. +type RetentionPolicy struct { + Enabled *bool `json:"enabled,omitempty"` + Days *int32 `json:"days,omitempty"` +} + +// RuleAction is the action that is performed when the alert rule becomes +// active, and when an alert condition is resolved. +type RuleAction struct { +} + +// RuleCondition is the condition that results in the alert rule being +// activated. +type RuleCondition struct { +} + +// RuleDataSource is the resource from which the rule collects its data. +type RuleDataSource struct { +} + +// RuleEmailAction is specifies the action to send email when the rule +// condition is evaluated. The discriminator is always RuleEmailAction in this +// case. +type RuleEmailAction struct { + SendToServiceOwners *bool `json:"sendToServiceOwners,omitempty"` + CustomEmails *[]string `json:"customEmails,omitempty"` +} + +// RuleManagementEventClaimsDataSource is the claims for a rule management +// event data source. +type RuleManagementEventClaimsDataSource struct { + EmailAddress *string `json:"emailAddress,omitempty"` +} + +// RuleManagementEventDataSource is a rule management event data source. The +// discriminator fields is always RuleManagementEventDataSource in this case. +type RuleManagementEventDataSource struct { + EventName *string `json:"eventName,omitempty"` + EventSource *string `json:"eventSource,omitempty"` + Level *string `json:"level,omitempty"` + OperationName *string `json:"operationName,omitempty"` + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + ResourceProviderName *string `json:"resourceProviderName,omitempty"` + ResourceURI *string `json:"resourceUri,omitempty"` + Status *string `json:"status,omitempty"` + SubStatus *string `json:"subStatus,omitempty"` + Claims *RuleManagementEventClaimsDataSource `json:"claims,omitempty"` +} + +// RuleMetricDataSource is a rule metric data source. The discriminator value +// is always RuleMetricDataSource in this case. +type RuleMetricDataSource struct { + ResourceURI *string `json:"resourceUri,omitempty"` + MetricName *string `json:"metricName,omitempty"` +} + +// RuleWebhookAction is specifies the action to post to service when the rule +// condition is evaluated. The discriminator is always RuleWebhookAction in +// this case. +type RuleWebhookAction struct { + ServiceURI *string `json:"serviceUri,omitempty"` + Properties *map[string]*string `json:"properties,omitempty"` +} + +// ScaleAction is the parameters for the scaling action. +type ScaleAction struct { + Direction ScaleDirection `json:"direction,omitempty"` + Type ScaleType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` + Cooldown *string `json:"cooldown,omitempty"` +} + +// ScaleCapacity is the number of instances that can be used during this +// profile. +type ScaleCapacity struct { + Minimum *string `json:"minimum,omitempty"` + Maximum *string `json:"maximum,omitempty"` + Default *string `json:"default,omitempty"` +} + +// ScaleRule is a rule that provide the triggers and parameters for the scaling +// action. +type ScaleRule struct { + MetricTrigger *MetricTrigger `json:"metricTrigger,omitempty"` + ScaleAction *ScaleAction `json:"scaleAction,omitempty"` +} + +// ServiceDiagnosticSettings is the diagnostic settings for service. +type ServiceDiagnosticSettings struct { + StorageAccountID *string `json:"storageAccountId,omitempty"` + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + Metrics *[]MetricSettings `json:"metrics,omitempty"` + Logs *[]LogSettings `json:"logs,omitempty"` + WorkspaceID *string `json:"workspaceId,omitempty"` +} + +// ServiceDiagnosticSettingsResource is description of a service diagnostic +// setting +type ServiceDiagnosticSettingsResource struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ServiceDiagnosticSettings `json:"properties,omitempty"` +} + +// ThresholdRuleCondition is a rule condition based on a metric crossing a +// threshold. +type ThresholdRuleCondition struct { + DataSource *RuleDataSource `json:"dataSource,omitempty"` + Operator ConditionOperator `json:"operator,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` + WindowSize *string `json:"windowSize,omitempty"` + TimeAggregation TimeAggregationOperator `json:"timeAggregation,omitempty"` +} + +// TimeWindow is a specific date-time for the profile. +type TimeWindow struct { + TimeZone *string `json:"timeZone,omitempty"` + Start *date.Time `json:"start,omitempty"` + End *date.Time `json:"end,omitempty"` +} + +// WebhookNotification is webhook notification of an autoscale event. +type WebhookNotification struct { + ServiceURI *string `json:"serviceUri,omitempty"` + Properties *map[string]*string `json:"properties,omitempty"` +} diff --git a/arm/insights/servicediagnosticsettings.go b/arm/insights/servicediagnosticsettings.go new file mode 100644 index 000000000000..bd061a1574c1 --- /dev/null +++ b/arm/insights/servicediagnosticsettings.go @@ -0,0 +1,173 @@ +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ServiceDiagnosticSettingsClient is the composite Swagger for Insights +// Management Client +type ServiceDiagnosticSettingsClient struct { + ManagementClient +} + +// NewServiceDiagnosticSettingsClient creates an instance of the +// ServiceDiagnosticSettingsClient client. +func NewServiceDiagnosticSettingsClient(subscriptionID string) ServiceDiagnosticSettingsClient { + return NewServiceDiagnosticSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceDiagnosticSettingsClientWithBaseURI creates an instance of the +// ServiceDiagnosticSettingsClient client. +func NewServiceDiagnosticSettingsClientWithBaseURI(baseURI string, subscriptionID string) ServiceDiagnosticSettingsClient { + return ServiceDiagnosticSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update new diagnostic settings for the specified +// resource. +// +// resourceURI is the identifier of the resource. parameters is parameters +// supplied to the operation. +func (client ServiceDiagnosticSettingsClient) CreateOrUpdate(resourceURI string, parameters ServiceDiagnosticSettingsResource) (result ServiceDiagnosticSettingsResource, err error) { + req, err := client.CreateOrUpdatePreparer(resourceURI, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ServiceDiagnosticSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ServiceDiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ServiceDiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServiceDiagnosticSettingsClient) CreateOrUpdatePreparer(resourceURI string, parameters ServiceDiagnosticSettingsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2015-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceDiagnosticSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServiceDiagnosticSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceDiagnosticSettingsResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the active diagnostic settings for the specified resource. +// +// resourceURI is the identifier of the resource. +func (client ServiceDiagnosticSettingsClient) Get(resourceURI string) (result ServiceDiagnosticSettingsResource, err error) { + req, err := client.GetPreparer(resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ServiceDiagnosticSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ServiceDiagnosticSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ServiceDiagnosticSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceDiagnosticSettingsClient) GetPreparer(resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": autorest.Encode("path", resourceURI), + } + + const APIVersion = "2015-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceDiagnosticSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceDiagnosticSettingsClient) GetResponder(resp *http.Response) (result ServiceDiagnosticSettingsResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/insights/version.go b/arm/insights/version.go new file mode 100644 index 000000000000..8913194ece4e --- /dev/null +++ b/arm/insights/version.go @@ -0,0 +1,29 @@ +package insights + +// Copyright (c) Microsoft and contributors. 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 1.0.1.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.0.0-beta arm-insights/" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.0.0-beta" +} diff --git a/arm/intune/android.go b/arm/intune/android.go index 2bb9399df8de..c9813666a778 100644 --- a/arm/intune/android.go +++ b/arm/intune/android.go @@ -56,13 +56,15 @@ func (client AndroidClient) AddAppForMAMPolicy(hostName string, policyName strin req, err := client.AddAppForMAMPolicyPreparer(hostName, policyName, appName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "AddAppForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "AddAppForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.AddAppForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "AddAppForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "AddAppForMAMPolicy", resp, "Failure sending request") + return } result, err = client.AddAppForMAMPolicyResponder(resp) @@ -81,8 +83,9 @@ func (client AndroidClient) AddAppForMAMPolicyPreparer(hostName string, policyNa "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -128,13 +131,15 @@ func (client AndroidClient) AddGroupForMAMPolicy(hostName string, policyName str req, err := client.AddGroupForMAMPolicyPreparer(hostName, policyName, groupID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "AddGroupForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "AddGroupForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.AddGroupForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "AddGroupForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "AddGroupForMAMPolicy", resp, "Failure sending request") + return } result, err = client.AddGroupForMAMPolicyResponder(resp) @@ -153,8 +158,9 @@ func (client AndroidClient) AddGroupForMAMPolicyPreparer(hostName string, policy "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -193,13 +199,15 @@ func (client AndroidClient) AddGroupForMAMPolicyResponder(resp *http.Response) ( func (client AndroidClient) CreateOrUpdateMAMPolicy(hostName string, policyName string, parameters AndroidMAMPolicy) (result AndroidMAMPolicy, err error) { req, err := client.CreateOrUpdateMAMPolicyPreparer(hostName, policyName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "CreateOrUpdateMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "CreateOrUpdateMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "CreateOrUpdateMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "CreateOrUpdateMAMPolicy", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateMAMPolicyResponder(resp) @@ -217,8 +225,9 @@ func (client AndroidClient) CreateOrUpdateMAMPolicyPreparer(hostName string, pol "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -257,13 +266,15 @@ func (client AndroidClient) CreateOrUpdateMAMPolicyResponder(resp *http.Response func (client AndroidClient) DeleteAppForMAMPolicy(hostName string, policyName string, appName string) (result autorest.Response, err error) { req, err := client.DeleteAppForMAMPolicyPreparer(hostName, policyName, appName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteAppForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteAppForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.DeleteAppForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteAppForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteAppForMAMPolicy", resp, "Failure sending request") + return } result, err = client.DeleteAppForMAMPolicyResponder(resp) @@ -282,8 +293,9 @@ func (client AndroidClient) DeleteAppForMAMPolicyPreparer(hostName string, polic "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -319,13 +331,15 @@ func (client AndroidClient) DeleteAppForMAMPolicyResponder(resp *http.Response) func (client AndroidClient) DeleteGroupForMAMPolicy(hostName string, policyName string, groupID string) (result autorest.Response, err error) { req, err := client.DeleteGroupForMAMPolicyPreparer(hostName, policyName, groupID) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteGroupForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteGroupForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.DeleteGroupForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteGroupForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteGroupForMAMPolicy", resp, "Failure sending request") + return } result, err = client.DeleteGroupForMAMPolicyResponder(resp) @@ -344,8 +358,9 @@ func (client AndroidClient) DeleteGroupForMAMPolicyPreparer(hostName string, pol "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -381,13 +396,15 @@ func (client AndroidClient) DeleteGroupForMAMPolicyResponder(resp *http.Response func (client AndroidClient) DeleteMAMPolicy(hostName string, policyName string) (result autorest.Response, err error) { req, err := client.DeleteMAMPolicyPreparer(hostName, policyName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.DeleteMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "DeleteMAMPolicy", resp, "Failure sending request") + return } result, err = client.DeleteMAMPolicyResponder(resp) @@ -405,8 +422,9 @@ func (client AndroidClient) DeleteMAMPolicyPreparer(hostName string, policyName "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -443,13 +461,15 @@ func (client AndroidClient) DeleteMAMPolicyResponder(resp *http.Response) (resul func (client AndroidClient) GetAppForMAMPolicy(hostName string, policyName string, filter string, top *int32, selectParameter string) (result ApplicationCollection, err error) { req, err := client.GetAppForMAMPolicyPreparer(hostName, policyName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetAppForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetAppForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.GetAppForMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetAppForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetAppForMAMPolicy", resp, "Failure sending request") + return } result, err = client.GetAppForMAMPolicyResponder(resp) @@ -467,8 +487,9 @@ func (client AndroidClient) GetAppForMAMPolicyPreparer(hostName string, policyNa "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -538,13 +559,15 @@ func (client AndroidClient) GetAppForMAMPolicyNextResults(lastResults Applicatio func (client AndroidClient) GetGroupsForMAMPolicy(hostName string, policyName string) (result GroupsCollection, err error) { req, err := client.GetGroupsForMAMPolicyPreparer(hostName, policyName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetGroupsForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetGroupsForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.GetGroupsForMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetGroupsForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetGroupsForMAMPolicy", resp, "Failure sending request") + return } result, err = client.GetGroupsForMAMPolicyResponder(resp) @@ -562,8 +585,9 @@ func (client AndroidClient) GetGroupsForMAMPolicyPreparer(hostName string, polic "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -624,13 +648,15 @@ func (client AndroidClient) GetGroupsForMAMPolicyNextResults(lastResults GroupsC func (client AndroidClient) GetMAMPolicies(hostName string, filter string, top *int32, selectParameter string) (result AndroidMAMPolicyCollection, err error) { req, err := client.GetMAMPoliciesPreparer(hostName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicies", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicies", nil, "Failure preparing request") + return } resp, err := client.GetMAMPoliciesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicies", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicies", resp, "Failure sending request") + return } result, err = client.GetMAMPoliciesResponder(resp) @@ -647,8 +673,9 @@ func (client AndroidClient) GetMAMPoliciesPreparer(hostName string, filter strin "hostName": autorest.Encode("path", hostName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -718,13 +745,15 @@ func (client AndroidClient) GetMAMPoliciesNextResults(lastResults AndroidMAMPoli func (client AndroidClient) GetMAMPolicyByName(hostName string, policyName string, selectParameter string) (result AndroidMAMPolicy, err error) { req, err := client.GetMAMPolicyByNamePreparer(hostName, policyName, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicyByName", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicyByName", nil, "Failure preparing request") + return } resp, err := client.GetMAMPolicyByNameSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicyByName", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "GetMAMPolicyByName", resp, "Failure sending request") + return } result, err = client.GetMAMPolicyByNameResponder(resp) @@ -742,8 +771,9 @@ func (client AndroidClient) GetMAMPolicyByNamePreparer(hostName string, policyNa "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(selectParameter) > 0 { queryParameters["$select"] = autorest.Encode("query", selectParameter) @@ -784,13 +814,15 @@ func (client AndroidClient) GetMAMPolicyByNameResponder(resp *http.Response) (re func (client AndroidClient) PatchMAMPolicy(hostName string, policyName string, parameters AndroidMAMPolicy) (result AndroidMAMPolicy, err error) { req, err := client.PatchMAMPolicyPreparer(hostName, policyName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "PatchMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "PatchMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.PatchMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.AndroidClient", "PatchMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.AndroidClient", "PatchMAMPolicy", resp, "Failure sending request") + return } result, err = client.PatchMAMPolicyResponder(resp) @@ -808,8 +840,9 @@ func (client AndroidClient) PatchMAMPolicyPreparer(hostName string, policyName s "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/intune/client.go b/arm/intune/client.go index f71884b67fa0..c5b0a0837a8b 100644 --- a/arm/intune/client.go +++ b/arm/intune/client.go @@ -30,9 +30,6 @@ import ( ) const ( - // APIVersion is the version of the Intune - APIVersion = "2015-01-14-preview" - // DefaultBaseURI is the default URI used for the service Intune DefaultBaseURI = "https://management.azure.com" ) @@ -40,8 +37,7 @@ const ( // ManagementClient is the base client for Intune. type ManagementClient struct { autorest.Client - BaseURI string - APIVersion string + BaseURI string } // New creates an instance of the ManagementClient client. @@ -52,9 +48,8 @@ func New() ManagementClient { // NewWithBaseURI creates an instance of the ManagementClient client. func NewWithBaseURI(baseURI string) ManagementClient { return ManagementClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - APIVersion: APIVersion, + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, } } @@ -65,13 +60,15 @@ func NewWithBaseURI(baseURI string) ManagementClient { func (client ManagementClient) GetApps(hostName string, filter string, top *int32, selectParameter string) (result ApplicationCollection, err error) { req, err := client.GetAppsPreparer(hostName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetApps", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetApps", nil, "Failure preparing request") + return } resp, err := client.GetAppsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetApps", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetApps", resp, "Failure sending request") + return } result, err = client.GetAppsResponder(resp) @@ -88,8 +85,9 @@ func (client ManagementClient) GetAppsPreparer(hostName string, filter string, t "hostName": autorest.Encode("path", hostName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -156,13 +154,15 @@ func (client ManagementClient) GetAppsNextResults(lastResults ApplicationCollect func (client ManagementClient) GetLocationByHostName() (result Location, err error) { req, err := client.GetLocationByHostNamePreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocationByHostName", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocationByHostName", nil, "Failure preparing request") + return } resp, err := client.GetLocationByHostNameSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocationByHostName", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocationByHostName", resp, "Failure sending request") + return } result, err = client.GetLocationByHostNameResponder(resp) @@ -175,8 +175,9 @@ func (client ManagementClient) GetLocationByHostName() (result Location, err err // GetLocationByHostNamePreparer prepares the GetLocationByHostName request. func (client ManagementClient) GetLocationByHostNamePreparer() (*http.Request, error) { + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -210,13 +211,15 @@ func (client ManagementClient) GetLocationByHostNameResponder(resp *http.Respons func (client ManagementClient) GetLocations() (result LocationCollection, err error) { req, err := client.GetLocationsPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocations", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocations", nil, "Failure preparing request") + return } resp, err := client.GetLocationsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocations", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetLocations", resp, "Failure sending request") + return } result, err = client.GetLocationsResponder(resp) @@ -229,8 +232,9 @@ func (client ManagementClient) GetLocations() (result LocationCollection, err er // GetLocationsPreparer prepares the GetLocations request. func (client ManagementClient) GetLocationsPreparer() (*http.Request, error) { + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -291,13 +295,15 @@ func (client ManagementClient) GetLocationsNextResults(lastResults LocationColle func (client ManagementClient) GetMAMFlaggedUserByName(hostName string, userName string, selectParameter string) (result FlaggedUser, err error) { req, err := client.GetMAMFlaggedUserByNamePreparer(hostName, userName, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUserByName", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUserByName", nil, "Failure preparing request") + return } resp, err := client.GetMAMFlaggedUserByNameSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUserByName", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUserByName", resp, "Failure sending request") + return } result, err = client.GetMAMFlaggedUserByNameResponder(resp) @@ -315,8 +321,9 @@ func (client ManagementClient) GetMAMFlaggedUserByNamePreparer(hostName string, "userName": autorest.Encode("path", userName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(selectParameter) > 0 { queryParameters["$select"] = autorest.Encode("query", selectParameter) @@ -356,13 +363,15 @@ func (client ManagementClient) GetMAMFlaggedUserByNameResponder(resp *http.Respo func (client ManagementClient) GetMAMFlaggedUsers(hostName string, filter string, top *int32, selectParameter string) (result FlaggedUserCollection, err error) { req, err := client.GetMAMFlaggedUsersPreparer(hostName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUsers", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUsers", nil, "Failure preparing request") + return } resp, err := client.GetMAMFlaggedUsersSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUsers", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMFlaggedUsers", resp, "Failure sending request") + return } result, err = client.GetMAMFlaggedUsersResponder(resp) @@ -379,8 +388,9 @@ func (client ManagementClient) GetMAMFlaggedUsersPreparer(hostName string, filte "hostName": autorest.Encode("path", hostName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -449,13 +459,15 @@ func (client ManagementClient) GetMAMFlaggedUsersNextResults(lastResults Flagged func (client ManagementClient) GetMAMStatuses(hostName string) (result StatusesDefault, err error) { req, err := client.GetMAMStatusesPreparer(hostName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMStatuses", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMStatuses", nil, "Failure preparing request") + return } resp, err := client.GetMAMStatusesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMStatuses", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMStatuses", resp, "Failure sending request") + return } result, err = client.GetMAMStatusesResponder(resp) @@ -472,8 +484,9 @@ func (client ManagementClient) GetMAMStatusesPreparer(hostName string) (*http.Re "hostName": autorest.Encode("path", hostName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -535,13 +548,15 @@ func (client ManagementClient) GetMAMStatusesNextResults(lastResults StatusesDef func (client ManagementClient) GetMAMUserDeviceByDeviceName(hostName string, userName string, deviceName string, selectParameter string) (result Device, err error) { req, err := client.GetMAMUserDeviceByDeviceNamePreparer(hostName, userName, deviceName, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDeviceByDeviceName", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDeviceByDeviceName", nil, "Failure preparing request") + return } resp, err := client.GetMAMUserDeviceByDeviceNameSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDeviceByDeviceName", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDeviceByDeviceName", resp, "Failure sending request") + return } result, err = client.GetMAMUserDeviceByDeviceNameResponder(resp) @@ -560,8 +575,9 @@ func (client ManagementClient) GetMAMUserDeviceByDeviceNamePreparer(hostName str "userName": autorest.Encode("path", userName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(selectParameter) > 0 { queryParameters["$select"] = autorest.Encode("query", selectParameter) @@ -602,13 +618,15 @@ func (client ManagementClient) GetMAMUserDeviceByDeviceNameResponder(resp *http. func (client ManagementClient) GetMAMUserDevices(hostName string, userName string, filter string, top *int32, selectParameter string) (result DeviceCollection, err error) { req, err := client.GetMAMUserDevicesPreparer(hostName, userName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDevices", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDevices", nil, "Failure preparing request") + return } resp, err := client.GetMAMUserDevicesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDevices", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserDevices", resp, "Failure sending request") + return } result, err = client.GetMAMUserDevicesResponder(resp) @@ -626,8 +644,9 @@ func (client ManagementClient) GetMAMUserDevicesPreparer(hostName string, userNa "userName": autorest.Encode("path", userName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -699,13 +718,15 @@ func (client ManagementClient) GetMAMUserDevicesNextResults(lastResults DeviceCo func (client ManagementClient) GetMAMUserFlaggedEnrolledApps(hostName string, userName string, filter string, top *int32, selectParameter string) (result FlaggedEnrolledAppCollection, err error) { req, err := client.GetMAMUserFlaggedEnrolledAppsPreparer(hostName, userName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserFlaggedEnrolledApps", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserFlaggedEnrolledApps", nil, "Failure preparing request") + return } resp, err := client.GetMAMUserFlaggedEnrolledAppsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserFlaggedEnrolledApps", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetMAMUserFlaggedEnrolledApps", resp, "Failure sending request") + return } result, err = client.GetMAMUserFlaggedEnrolledAppsResponder(resp) @@ -723,8 +744,9 @@ func (client ManagementClient) GetMAMUserFlaggedEnrolledAppsPreparer(hostName st "userName": autorest.Encode("path", userName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -794,13 +816,15 @@ func (client ManagementClient) GetMAMUserFlaggedEnrolledAppsNextResults(lastResu func (client ManagementClient) GetOperationResults(hostName string, filter string, top *int32, selectParameter string) (result OperationResultCollection, err error) { req, err := client.GetOperationResultsPreparer(hostName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetOperationResults", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetOperationResults", nil, "Failure preparing request") + return } resp, err := client.GetOperationResultsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "GetOperationResults", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "GetOperationResults", resp, "Failure sending request") + return } result, err = client.GetOperationResultsResponder(resp) @@ -817,8 +841,9 @@ func (client ManagementClient) GetOperationResultsPreparer(hostName string, filt "hostName": autorest.Encode("path", hostName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -888,13 +913,15 @@ func (client ManagementClient) GetOperationResultsNextResults(lastResults Operat func (client ManagementClient) WipeMAMUserDevice(hostName string, userName string, deviceName string) (result WipeDeviceOperationResult, err error) { req, err := client.WipeMAMUserDevicePreparer(hostName, userName, deviceName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "WipeMAMUserDevice", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "WipeMAMUserDevice", nil, "Failure preparing request") + return } resp, err := client.WipeMAMUserDeviceSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.ManagementClient", "WipeMAMUserDevice", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.ManagementClient", "WipeMAMUserDevice", resp, "Failure sending request") + return } result, err = client.WipeMAMUserDeviceResponder(resp) @@ -913,8 +940,9 @@ func (client ManagementClient) WipeMAMUserDevicePreparer(hostName string, userNa "userName": autorest.Encode("path", userName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/intune/ios.go b/arm/intune/ios.go index 85a751d354f8..bcd4edd66cbf 100644 --- a/arm/intune/ios.go +++ b/arm/intune/ios.go @@ -56,13 +56,15 @@ func (client IosClient) AddAppForMAMPolicy(hostName string, policyName string, a req, err := client.AddAppForMAMPolicyPreparer(hostName, policyName, appName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "AddAppForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "AddAppForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.AddAppForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.IosClient", "AddAppForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "AddAppForMAMPolicy", resp, "Failure sending request") + return } result, err = client.AddAppForMAMPolicyResponder(resp) @@ -81,8 +83,9 @@ func (client IosClient) AddAppForMAMPolicyPreparer(hostName string, policyName s "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -128,13 +131,15 @@ func (client IosClient) AddGroupForMAMPolicy(hostName string, policyName string, req, err := client.AddGroupForMAMPolicyPreparer(hostName, policyName, groupID, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "AddGroupForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "AddGroupForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.AddGroupForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.IosClient", "AddGroupForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "AddGroupForMAMPolicy", resp, "Failure sending request") + return } result, err = client.AddGroupForMAMPolicyResponder(resp) @@ -153,8 +158,9 @@ func (client IosClient) AddGroupForMAMPolicyPreparer(hostName string, policyName "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -193,13 +199,15 @@ func (client IosClient) AddGroupForMAMPolicyResponder(resp *http.Response) (resu func (client IosClient) CreateOrUpdateMAMPolicy(hostName string, policyName string, parameters IOSMAMPolicy) (result IOSMAMPolicy, err error) { req, err := client.CreateOrUpdateMAMPolicyPreparer(hostName, policyName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "CreateOrUpdateMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "CreateOrUpdateMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.IosClient", "CreateOrUpdateMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "CreateOrUpdateMAMPolicy", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateMAMPolicyResponder(resp) @@ -217,8 +225,9 @@ func (client IosClient) CreateOrUpdateMAMPolicyPreparer(hostName string, policyN "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -257,13 +266,15 @@ func (client IosClient) CreateOrUpdateMAMPolicyResponder(resp *http.Response) (r func (client IosClient) DeleteAppForMAMPolicy(hostName string, policyName string, appName string) (result autorest.Response, err error) { req, err := client.DeleteAppForMAMPolicyPreparer(hostName, policyName, appName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "DeleteAppForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "DeleteAppForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.DeleteAppForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.IosClient", "DeleteAppForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "DeleteAppForMAMPolicy", resp, "Failure sending request") + return } result, err = client.DeleteAppForMAMPolicyResponder(resp) @@ -282,8 +293,9 @@ func (client IosClient) DeleteAppForMAMPolicyPreparer(hostName string, policyNam "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -319,13 +331,15 @@ func (client IosClient) DeleteAppForMAMPolicyResponder(resp *http.Response) (res func (client IosClient) DeleteGroupForMAMPolicy(hostName string, policyName string, groupID string) (result autorest.Response, err error) { req, err := client.DeleteGroupForMAMPolicyPreparer(hostName, policyName, groupID) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "DeleteGroupForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "DeleteGroupForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.DeleteGroupForMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.IosClient", "DeleteGroupForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "DeleteGroupForMAMPolicy", resp, "Failure sending request") + return } result, err = client.DeleteGroupForMAMPolicyResponder(resp) @@ -344,8 +358,9 @@ func (client IosClient) DeleteGroupForMAMPolicyPreparer(hostName string, policyN "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -381,13 +396,15 @@ func (client IosClient) DeleteGroupForMAMPolicyResponder(resp *http.Response) (r func (client IosClient) DeleteMAMPolicy(hostName string, policyName string) (result autorest.Response, err error) { req, err := client.DeleteMAMPolicyPreparer(hostName, policyName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "DeleteMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "DeleteMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.DeleteMAMPolicySender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "intune.IosClient", "DeleteMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "DeleteMAMPolicy", resp, "Failure sending request") + return } result, err = client.DeleteMAMPolicyResponder(resp) @@ -405,8 +422,9 @@ func (client IosClient) DeleteMAMPolicyPreparer(hostName string, policyName stri "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -443,13 +461,15 @@ func (client IosClient) DeleteMAMPolicyResponder(resp *http.Response) (result au func (client IosClient) GetAppForMAMPolicy(hostName string, policyName string, filter string, top *int32, selectParameter string) (result ApplicationCollection, err error) { req, err := client.GetAppForMAMPolicyPreparer(hostName, policyName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetAppForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetAppForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.GetAppForMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetAppForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetAppForMAMPolicy", resp, "Failure sending request") + return } result, err = client.GetAppForMAMPolicyResponder(resp) @@ -467,8 +487,9 @@ func (client IosClient) GetAppForMAMPolicyPreparer(hostName string, policyName s "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -538,13 +559,15 @@ func (client IosClient) GetAppForMAMPolicyNextResults(lastResults ApplicationCol func (client IosClient) GetGroupsForMAMPolicy(hostName string, policyName string) (result GroupsCollection, err error) { req, err := client.GetGroupsForMAMPolicyPreparer(hostName, policyName) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetGroupsForMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetGroupsForMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.GetGroupsForMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetGroupsForMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetGroupsForMAMPolicy", resp, "Failure sending request") + return } result, err = client.GetGroupsForMAMPolicyResponder(resp) @@ -562,8 +585,9 @@ func (client IosClient) GetGroupsForMAMPolicyPreparer(hostName string, policyNam "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -624,13 +648,15 @@ func (client IosClient) GetGroupsForMAMPolicyNextResults(lastResults GroupsColle func (client IosClient) GetMAMPolicies(hostName string, filter string, top *int32, selectParameter string) (result IOSMAMPolicyCollection, err error) { req, err := client.GetMAMPoliciesPreparer(hostName, filter, top, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicies", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicies", nil, "Failure preparing request") + return } resp, err := client.GetMAMPoliciesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicies", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicies", resp, "Failure sending request") + return } result, err = client.GetMAMPoliciesResponder(resp) @@ -647,8 +673,9 @@ func (client IosClient) GetMAMPoliciesPreparer(hostName string, filter string, t "hostName": autorest.Encode("path", hostName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(filter) > 0 { queryParameters["$filter"] = autorest.Encode("query", filter) @@ -718,13 +745,15 @@ func (client IosClient) GetMAMPoliciesNextResults(lastResults IOSMAMPolicyCollec func (client IosClient) GetMAMPolicyByName(hostName string, policyName string, selectParameter string) (result IOSMAMPolicy, err error) { req, err := client.GetMAMPolicyByNamePreparer(hostName, policyName, selectParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicyByName", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicyByName", nil, "Failure preparing request") + return } resp, err := client.GetMAMPolicyByNameSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicyByName", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "GetMAMPolicyByName", resp, "Failure sending request") + return } result, err = client.GetMAMPolicyByNameResponder(resp) @@ -742,8 +771,9 @@ func (client IosClient) GetMAMPolicyByNamePreparer(hostName string, policyName s "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(selectParameter) > 0 { queryParameters["$select"] = autorest.Encode("query", selectParameter) @@ -784,13 +814,15 @@ func (client IosClient) GetMAMPolicyByNameResponder(resp *http.Response) (result func (client IosClient) PatchMAMPolicy(hostName string, policyName string, parameters IOSMAMPolicy) (result IOSMAMPolicy, err error) { req, err := client.PatchMAMPolicyPreparer(hostName, policyName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "intune.IosClient", "PatchMAMPolicy", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "PatchMAMPolicy", nil, "Failure preparing request") + return } resp, err := client.PatchMAMPolicySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "intune.IosClient", "PatchMAMPolicy", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "intune.IosClient", "PatchMAMPolicy", resp, "Failure sending request") + return } result, err = client.PatchMAMPolicyResponder(resp) @@ -808,8 +840,9 @@ func (client IosClient) PatchMAMPolicyPreparer(hostName string, policyName strin "policyName": autorest.Encode("path", policyName), } + const APIVersion = "2015-01-14-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/intune/version.go b/arm/intune/version.go index 47860fc1907c..8865cdf607c4 100644 --- a/arm/intune/version.go +++ b/arm/intune/version.go @@ -18,43 +18,12 @@ package intune // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "intune", "2015-01-14-preview") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.0-beta arm-intune/2015-01-14-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.0-beta" } diff --git a/arm/iothub/resource.go b/arm/iothub/resource.go index 37406dc8b459..83b97042999c 100755 --- a/arm/iothub/resource.go +++ b/arm/iothub/resource.go @@ -55,13 +55,15 @@ func (client ResourceClient) CheckNameAvailability(operationInputs OperationInpu req, err := client.CheckNameAvailabilityPreparer(operationInputs) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "CheckNameAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CheckNameAvailability", nil, "Failure preparing request") + return } resp, err := client.CheckNameAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "CheckNameAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CheckNameAvailability", resp, "Failure sending request") + return } result, err = client.CheckNameAvailabilityResponder(resp) @@ -122,13 +124,15 @@ func (client ResourceClient) CheckNameAvailabilityResponder(resp *http.Response) func (client ResourceClient) CreateEventHubConsumerGroup(resourceGroupName string, resourceName string, eventHubEndpointName string, name string) (result EventHubConsumerGroupInfo, err error) { req, err := client.CreateEventHubConsumerGroupPreparer(resourceGroupName, resourceName, eventHubEndpointName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateEventHubConsumerGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateEventHubConsumerGroup", nil, "Failure preparing request") + return } resp, err := client.CreateEventHubConsumerGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateEventHubConsumerGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateEventHubConsumerGroup", resp, "Failure sending request") + return } result, err = client.CreateEventHubConsumerGroupResponder(resp) @@ -191,7 +195,9 @@ func (client ResourceClient) CreateEventHubConsumerGroupResponder(resp *http.Res // resourceGroupName is the name of the resource group that contains the IoT // hub. resourceName is the name of the IoT hub to create or update. // iotHubDescription is the IoT hub metadata and security metadata. -func (client ResourceClient) CreateOrUpdate(resourceGroupName string, resourceName string, iotHubDescription Description, cancel <-chan struct{}) (result autorest.Response, err error) { +func (client ResourceClient) CreateOrUpdate(resourceGroupName string, resourceName string, iotHubDescription Description, cancel <-chan struct{}) (<-chan Description, <-chan error) { + resultChan := make(chan Description, 1) + errChan := make(chan error, 1) if err := validation.Validate([]validation.Validation{ {TargetValue: iotHubDescription, Constraints: []validation.Constraint{{Target: "iotHubDescription.Subscriptionid", Name: validation.Null, Rule: true, Chain: nil}, @@ -212,26 +218,40 @@ func (client ResourceClient) CreateOrUpdate(resourceGroupName string, resourceNa }}, {Target: "iotHubDescription.Sku", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "iotHubDescription.Sku.Capacity", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "iothub.ResourceClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceName, iotHubDescription, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return + errChan <- validation.NewErrorWithValidationError(err, "iothub.ResourceClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Description + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceName, iotHubDescription, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. @@ -267,13 +287,14 @@ func (client ResourceClient) CreateOrUpdateSender(req *http.Request) (*http.Resp // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client ResourceClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ResourceClient) CreateOrUpdateResponder(resp *http.Response) (result Description, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -283,24 +304,37 @@ func (client ResourceClient) CreateOrUpdateResponder(resp *http.Response) (resul // // resourceGroupName is the name of the resource group that contains the IoT // hub. resourceName is the name of the IoT hub to delete. -func (client ResourceClient) Delete(resourceGroupName string, resourceName string, cancel <-chan struct{}) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, resourceName, cancel) - if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "Delete", resp, "Failure responding to request") - } - - return +func (client ResourceClient) Delete(resourceGroupName string, resourceName string, cancel <-chan struct{}) (<-chan SetObject, <-chan error) { + resultChan := make(chan SetObject, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result SetObject + defer func() { + resultChan <- result + errChan <- err + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, resourceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan } // DeletePreparer prepares the Delete request. @@ -334,13 +368,14 @@ func (client ResourceClient) DeleteSender(req *http.Request) (*http.Response, er // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. -func (client ResourceClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ResourceClient) DeleteResponder(resp *http.Response) (result SetObject, err error) { err = autorest.Respond( resp, client.ByInspecting(), azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result.Value), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -354,13 +389,15 @@ func (client ResourceClient) DeleteResponder(resp *http.Response) (result autore func (client ResourceClient) DeleteEventHubConsumerGroup(resourceGroupName string, resourceName string, eventHubEndpointName string, name string) (result autorest.Response, err error) { req, err := client.DeleteEventHubConsumerGroupPreparer(resourceGroupName, resourceName, eventHubEndpointName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "DeleteEventHubConsumerGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "DeleteEventHubConsumerGroup", nil, "Failure preparing request") + return } resp, err := client.DeleteEventHubConsumerGroupSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "DeleteEventHubConsumerGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "DeleteEventHubConsumerGroup", resp, "Failure sending request") + return } result, err = client.DeleteEventHubConsumerGroupResponder(resp) @@ -429,13 +466,15 @@ func (client ResourceClient) ExportDevices(resourceGroupName string, resourceNam req, err := client.ExportDevicesPreparer(resourceGroupName, resourceName, exportDevicesParameters) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ExportDevices", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ExportDevices", nil, "Failure preparing request") + return } resp, err := client.ExportDevicesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ExportDevices", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ExportDevices", resp, "Failure sending request") + return } result, err = client.ExportDevicesResponder(resp) @@ -495,13 +534,15 @@ func (client ResourceClient) ExportDevicesResponder(resp *http.Response) (result func (client ResourceClient) Get(resourceGroupName string, resourceName string) (result Description, err error) { req, err := client.GetPreparer(resourceGroupName, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -562,13 +603,15 @@ func (client ResourceClient) GetResponder(resp *http.Response) (result Descripti func (client ResourceClient) GetEventHubConsumerGroup(resourceGroupName string, resourceName string, eventHubEndpointName string, name string) (result EventHubConsumerGroupInfo, err error) { req, err := client.GetEventHubConsumerGroupPreparer(resourceGroupName, resourceName, eventHubEndpointName, name) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetEventHubConsumerGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetEventHubConsumerGroup", nil, "Failure preparing request") + return } resp, err := client.GetEventHubConsumerGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetEventHubConsumerGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetEventHubConsumerGroup", resp, "Failure sending request") + return } result, err = client.GetEventHubConsumerGroupResponder(resp) @@ -629,13 +672,15 @@ func (client ResourceClient) GetEventHubConsumerGroupResponder(resp *http.Respon func (client ResourceClient) GetJob(resourceGroupName string, resourceName string, jobID string) (result JobResponse, err error) { req, err := client.GetJobPreparer(resourceGroupName, resourceName, jobID) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetJob", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetJob", nil, "Failure preparing request") + return } resp, err := client.GetJobSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetJob", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetJob", resp, "Failure sending request") + return } result, err = client.GetJobResponder(resp) @@ -697,13 +742,15 @@ func (client ResourceClient) GetJobResponder(resp *http.Response) (result JobRes func (client ResourceClient) GetKeysForKeyName(resourceGroupName string, resourceName string, keyName string) (result SharedAccessSignatureAuthorizationRule, err error) { req, err := client.GetKeysForKeyNamePreparer(resourceGroupName, resourceName, keyName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetKeysForKeyName", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetKeysForKeyName", nil, "Failure preparing request") + return } resp, err := client.GetKeysForKeyNameSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetKeysForKeyName", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetKeysForKeyName", resp, "Failure sending request") + return } result, err = client.GetKeysForKeyNameResponder(resp) @@ -762,13 +809,15 @@ func (client ResourceClient) GetKeysForKeyNameResponder(resp *http.Response) (re func (client ResourceClient) GetQuotaMetrics(resourceGroupName string, resourceName string) (result QuotaMetricInfoListResult, err error) { req, err := client.GetQuotaMetricsPreparer(resourceGroupName, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetQuotaMetrics", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetQuotaMetrics", nil, "Failure preparing request") + return } resp, err := client.GetQuotaMetricsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetQuotaMetrics", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetQuotaMetrics", resp, "Failure sending request") + return } result, err = client.GetQuotaMetricsResponder(resp) @@ -850,13 +899,15 @@ func (client ResourceClient) GetQuotaMetricsNextResults(lastResults QuotaMetricI func (client ResourceClient) GetStats(resourceGroupName string, resourceName string) (result RegistryStatistics, err error) { req, err := client.GetStatsPreparer(resourceGroupName, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetStats", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetStats", nil, "Failure preparing request") + return } resp, err := client.GetStatsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetStats", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetStats", resp, "Failure sending request") + return } result, err = client.GetStatsResponder(resp) @@ -914,13 +965,15 @@ func (client ResourceClient) GetStatsResponder(resp *http.Response) (result Regi func (client ResourceClient) GetValidSkus(resourceGroupName string, resourceName string) (result SkuDescriptionListResult, err error) { req, err := client.GetValidSkusPreparer(resourceGroupName, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetValidSkus", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetValidSkus", nil, "Failure preparing request") + return } resp, err := client.GetValidSkusSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetValidSkus", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "GetValidSkus", resp, "Failure sending request") + return } result, err = client.GetValidSkusResponder(resp) @@ -1012,13 +1065,15 @@ func (client ResourceClient) ImportDevices(resourceGroupName string, resourceNam req, err := client.ImportDevicesPreparer(resourceGroupName, resourceName, importDevicesParameters) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ImportDevices", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ImportDevices", nil, "Failure preparing request") + return } resp, err := client.ImportDevicesSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ImportDevices", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ImportDevices", resp, "Failure sending request") + return } result, err = client.ImportDevicesResponder(resp) @@ -1078,13 +1133,15 @@ func (client ResourceClient) ImportDevicesResponder(resp *http.Response) (result func (client ResourceClient) ListByResourceGroup(resourceGroupName string) (result DescriptionListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -1162,13 +1219,15 @@ func (client ResourceClient) ListByResourceGroupNextResults(lastResults Descript func (client ResourceClient) ListBySubscription() (result DescriptionListResult, err error) { req, err := client.ListBySubscriptionPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListBySubscription", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListBySubscription", nil, "Failure preparing request") + return } resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListBySubscription", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListBySubscription", resp, "Failure sending request") + return } result, err = client.ListBySubscriptionResponder(resp) @@ -1250,13 +1309,15 @@ func (client ResourceClient) ListBySubscriptionNextResults(lastResults Descripti func (client ResourceClient) ListEventHubConsumerGroups(resourceGroupName string, resourceName string, eventHubEndpointName string) (result EventHubConsumerGroupsListResult, err error) { req, err := client.ListEventHubConsumerGroupsPreparer(resourceGroupName, resourceName, eventHubEndpointName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListEventHubConsumerGroups", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListEventHubConsumerGroups", nil, "Failure preparing request") + return } resp, err := client.ListEventHubConsumerGroupsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListEventHubConsumerGroups", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListEventHubConsumerGroups", resp, "Failure sending request") + return } result, err = client.ListEventHubConsumerGroupsResponder(resp) @@ -1341,13 +1402,15 @@ func (client ResourceClient) ListEventHubConsumerGroupsNextResults(lastResults E func (client ResourceClient) ListJobs(resourceGroupName string, resourceName string) (result JobResponseListResult, err error) { req, err := client.ListJobsPreparer(resourceGroupName, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListJobs", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListJobs", nil, "Failure preparing request") + return } resp, err := client.ListJobsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListJobs", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListJobs", resp, "Failure sending request") + return } result, err = client.ListJobsResponder(resp) @@ -1430,13 +1493,15 @@ func (client ResourceClient) ListJobsNextResults(lastResults JobResponseListResu func (client ResourceClient) ListKeys(resourceGroupName string, resourceName string) (result SharedAccessSignatureAuthorizationRuleListResult, err error) { req, err := client.ListKeysPreparer(resourceGroupName, resourceName) if err != nil { - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListKeys", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListKeys", nil, "Failure preparing request") + return } resp, err := client.ListKeysSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListKeys", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "iothub.ResourceClient", "ListKeys", resp, "Failure sending request") + return } result, err = client.ListKeysResponder(resp) diff --git a/arm/iothub/version.go b/arm/iothub/version.go index a9ba3732bae2..d9eac4396b01 100755 --- a/arm/iothub/version.go +++ b/arm/iothub/version.go @@ -20,10 +20,10 @@ package iothub // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-iothub/2016-02-03" + return "Azure-SDK-For-Go/v10.0.0-beta arm-iothub/2016-02-03" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/keyvault/vaults.go b/arm/keyvault/vaults.go index 47cfb26e72b9..5b8c021ed0cf 100755 --- a/arm/keyvault/vaults.go +++ b/arm/keyvault/vaults.go @@ -64,13 +64,15 @@ func (client VaultsClient) CreateOrUpdate(resourceGroupName string, vaultName st req, err := client.CreateOrUpdatePreparer(resourceGroupName, vaultName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -130,13 +132,15 @@ func (client VaultsClient) CreateOrUpdateResponder(resp *http.Response) (result func (client VaultsClient) Delete(resourceGroupName string, vaultName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, vaultName) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -193,13 +197,15 @@ func (client VaultsClient) DeleteResponder(resp *http.Response) (result autorest func (client VaultsClient) Get(resourceGroupName string, vaultName string) (result Vault, err error) { req, err := client.GetPreparer(resourceGroupName, vaultName) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -258,13 +264,15 @@ func (client VaultsClient) GetResponder(resp *http.Response) (result Vault, err func (client VaultsClient) List(filter string, top *int32) (result ResourceListResult, err error) { req, err := client.ListPreparer(filter, top) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -349,13 +357,15 @@ func (client VaultsClient) ListNextResults(lastResults ResourceListResult) (resu func (client VaultsClient) ListByResourceGroup(resourceGroupName string, top *int32) (result VaultListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) diff --git a/arm/keyvault/version.go b/arm/keyvault/version.go index 921872a3f4ba..74eefa1ea0e3 100755 --- a/arm/keyvault/version.go +++ b/arm/keyvault/version.go @@ -20,10 +20,10 @@ package keyvault // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-keyvault/2015-06-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-keyvault/2015-06-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/logic/agreements.go b/arm/logic/agreements.go index c67fbbce2529..20a2bd1b9432 100755 --- a/arm/logic/agreements.go +++ b/arm/logic/agreements.go @@ -484,13 +484,15 @@ func (client AgreementsClient) CreateOrUpdate(resourceGroupName string, integrat req, err := client.CreateOrUpdatePreparer(resourceGroupName, integrationAccountName, agreementName, agreement) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -552,13 +554,15 @@ func (client AgreementsClient) CreateOrUpdateResponder(resp *http.Response) (res func (client AgreementsClient) Delete(resourceGroupName string, integrationAccountName string, agreementName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, integrationAccountName, agreementName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -617,13 +621,15 @@ func (client AgreementsClient) DeleteResponder(resp *http.Response) (result auto func (client AgreementsClient) Get(resourceGroupName string, integrationAccountName string, agreementName string) (result IntegrationAccountAgreement, err error) { req, err := client.GetPreparer(resourceGroupName, integrationAccountName, agreementName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -683,13 +689,15 @@ func (client AgreementsClient) GetResponder(resp *http.Response) (result Integra func (client AgreementsClient) ListByIntegrationAccounts(resourceGroupName string, integrationAccountName string, top *int32, filter string) (result IntegrationAccountAgreementListResult, err error) { req, err := client.ListByIntegrationAccountsPreparer(resourceGroupName, integrationAccountName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + return } resp, err := client.ListByIntegrationAccountsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.AgreementsClient", "ListByIntegrationAccounts", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.AgreementsClient", "ListByIntegrationAccounts", resp, "Failure sending request") + return } result, err = client.ListByIntegrationAccountsResponder(resp) diff --git a/arm/logic/certificates.go b/arm/logic/certificates.go index 9acaeb7173dd..04f3e7596a2c 100755 --- a/arm/logic/certificates.go +++ b/arm/logic/certificates.go @@ -60,13 +60,15 @@ func (client CertificatesClient) CreateOrUpdate(resourceGroupName string, integr req, err := client.CreateOrUpdatePreparer(resourceGroupName, integrationAccountName, certificateName, certificate) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -128,13 +130,15 @@ func (client CertificatesClient) CreateOrUpdateResponder(resp *http.Response) (r func (client CertificatesClient) Delete(resourceGroupName string, integrationAccountName string, certificateName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, integrationAccountName, certificateName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -193,13 +197,15 @@ func (client CertificatesClient) DeleteResponder(resp *http.Response) (result au func (client CertificatesClient) Get(resourceGroupName string, integrationAccountName string, certificateName string) (result IntegrationAccountCertificate, err error) { req, err := client.GetPreparer(resourceGroupName, integrationAccountName, certificateName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -259,13 +265,15 @@ func (client CertificatesClient) GetResponder(resp *http.Response) (result Integ func (client CertificatesClient) ListByIntegrationAccounts(resourceGroupName string, integrationAccountName string, top *int32) (result IntegrationAccountCertificateListResult, err error) { req, err := client.ListByIntegrationAccountsPreparer(resourceGroupName, integrationAccountName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + return } resp, err := client.ListByIntegrationAccountsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.CertificatesClient", "ListByIntegrationAccounts", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.CertificatesClient", "ListByIntegrationAccounts", resp, "Failure sending request") + return } result, err = client.ListByIntegrationAccountsResponder(resp) diff --git a/arm/logic/client.go b/arm/logic/client.go index 0238088fdbd4..673d79956bff 100755 --- a/arm/logic/client.go +++ b/arm/logic/client.go @@ -57,13 +57,15 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { func (client ManagementClient) ListOperations() (result OperationListResult, err error) { req, err := client.ListOperationsPreparer() if err != nil { - return result, autorest.NewErrorWithError(err, "logic.ManagementClient", "ListOperations", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.ManagementClient", "ListOperations", nil, "Failure preparing request") + return } resp, err := client.ListOperationsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.ManagementClient", "ListOperations", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.ManagementClient", "ListOperations", resp, "Failure sending request") + return } result, err = client.ListOperationsResponder(resp) diff --git a/arm/logic/integrationaccounts.go b/arm/logic/integrationaccounts.go index 723744cbf75b..9de0b8072eef 100755 --- a/arm/logic/integrationaccounts.go +++ b/arm/logic/integrationaccounts.go @@ -48,13 +48,15 @@ func NewIntegrationAccountsClientWithBaseURI(baseURI string, subscriptionID stri func (client IntegrationAccountsClient) CreateOrUpdate(resourceGroupName string, integrationAccountName string, integrationAccount IntegrationAccount) (result IntegrationAccount, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, integrationAccountName, integrationAccount) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -114,13 +116,15 @@ func (client IntegrationAccountsClient) CreateOrUpdateResponder(resp *http.Respo func (client IntegrationAccountsClient) Delete(resourceGroupName string, integrationAccountName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, integrationAccountName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -177,13 +181,15 @@ func (client IntegrationAccountsClient) DeleteResponder(resp *http.Response) (re func (client IntegrationAccountsClient) Get(resourceGroupName string, integrationAccountName string) (result IntegrationAccount, err error) { req, err := client.GetPreparer(resourceGroupName, integrationAccountName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -241,13 +247,15 @@ func (client IntegrationAccountsClient) GetResponder(resp *http.Response) (resul func (client IntegrationAccountsClient) GetCallbackURL(resourceGroupName string, integrationAccountName string, parameters GetCallbackURLParameters) (result CallbackURL, err error) { req, err := client.GetCallbackURLPreparer(resourceGroupName, integrationAccountName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "GetCallbackURL", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "GetCallbackURL", nil, "Failure preparing request") + return } resp, err := client.GetCallbackURLSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "GetCallbackURL", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "GetCallbackURL", resp, "Failure sending request") + return } result, err = client.GetCallbackURLResponder(resp) @@ -307,13 +315,15 @@ func (client IntegrationAccountsClient) GetCallbackURLResponder(resp *http.Respo func (client IntegrationAccountsClient) ListByResourceGroup(resourceGroupName string, top *int32) (result IntegrationAccountListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -396,13 +406,15 @@ func (client IntegrationAccountsClient) ListByResourceGroupNextResults(lastResul func (client IntegrationAccountsClient) ListBySubscription(top *int32) (result IntegrationAccountListResult, err error) { req, err := client.ListBySubscriptionPreparer(top) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListBySubscription", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListBySubscription", nil, "Failure preparing request") + return } resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListBySubscription", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "ListBySubscription", resp, "Failure sending request") + return } result, err = client.ListBySubscriptionResponder(resp) @@ -485,13 +497,15 @@ func (client IntegrationAccountsClient) ListBySubscriptionNextResults(lastResult func (client IntegrationAccountsClient) Update(resourceGroupName string, integrationAccountName string, integrationAccount IntegrationAccount) (result IntegrationAccount, err error) { req, err := client.UpdatePreparer(resourceGroupName, integrationAccountName, integrationAccount) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.IntegrationAccountsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) diff --git a/arm/logic/maps.go b/arm/logic/maps.go index 14b8cd094707..40ca83df49aa 100755 --- a/arm/logic/maps.go +++ b/arm/logic/maps.go @@ -54,13 +54,15 @@ func (client MapsClient) CreateOrUpdate(resourceGroupName string, integrationAcc req, err := client.CreateOrUpdatePreparer(resourceGroupName, integrationAccountName, mapName, mapParameter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -121,13 +123,15 @@ func (client MapsClient) CreateOrUpdateResponder(resp *http.Response) (result In func (client MapsClient) Delete(resourceGroupName string, integrationAccountName string, mapName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, integrationAccountName, mapName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -185,13 +189,15 @@ func (client MapsClient) DeleteResponder(resp *http.Response) (result autorest.R func (client MapsClient) Get(resourceGroupName string, integrationAccountName string, mapName string) (result IntegrationAccountMap, err error) { req, err := client.GetPreparer(resourceGroupName, integrationAccountName, mapName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -251,13 +257,15 @@ func (client MapsClient) GetResponder(resp *http.Response) (result IntegrationAc func (client MapsClient) ListByIntegrationAccounts(resourceGroupName string, integrationAccountName string, top *int32, filter string) (result IntegrationAccountMapListResult, err error) { req, err := client.ListByIntegrationAccountsPreparer(resourceGroupName, integrationAccountName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + return } resp, err := client.ListByIntegrationAccountsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.MapsClient", "ListByIntegrationAccounts", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListByIntegrationAccounts", resp, "Failure sending request") + return } result, err = client.ListByIntegrationAccountsResponder(resp) diff --git a/arm/logic/models.go b/arm/logic/models.go index 96a91346a16f..159cda6dc3d4 100755 --- a/arm/logic/models.go +++ b/arm/logic/models.go @@ -367,6 +367,30 @@ const ( SegmentTerminatorSuffixNotSpecified SegmentTerminatorSuffix = "NotSpecified" ) +// SigningAlgorithm enumerates the values for signing algorithm. +type SigningAlgorithm string + +const ( + // SigningAlgorithmDefault specifies the signing algorithm default state + // for signing algorithm. + SigningAlgorithmDefault SigningAlgorithm = "Default" + // SigningAlgorithmNotSpecified specifies the signing algorithm not + // specified state for signing algorithm. + SigningAlgorithmNotSpecified SigningAlgorithm = "NotSpecified" + // SigningAlgorithmSHA1 specifies the signing algorithm sha1 state for + // signing algorithm. + SigningAlgorithmSHA1 SigningAlgorithm = "SHA1" + // SigningAlgorithmSHA2256 specifies the signing algorithm sha2256 state + // for signing algorithm. + SigningAlgorithmSHA2256 SigningAlgorithm = "SHA2256" + // SigningAlgorithmSHA2384 specifies the signing algorithm sha2384 state + // for signing algorithm. + SigningAlgorithmSHA2384 SigningAlgorithm = "SHA2384" + // SigningAlgorithmSHA2512 specifies the signing algorithm sha2512 state + // for signing algorithm. + SigningAlgorithmSHA2512 SigningAlgorithm = "SHA2512" +) + // SkuName enumerates the values for sku name. type SkuName string @@ -770,6 +794,7 @@ type AS2SecuritySettings struct { EnableNrrForOutboundEncodedMessages *bool `json:"enableNrrForOutboundEncodedMessages,omitempty"` EnableNrrForOutboundDecodedMessages *bool `json:"enableNrrForOutboundDecodedMessages,omitempty"` EnableNrrForInboundMdn *bool `json:"enableNrrForInboundMdn,omitempty"` + Sha2AlgorithmFormat *string `json:"sha2AlgorithmFormat,omitempty"` } // AS2ValidationSettings is the AS2 agreement validation settings. @@ -783,6 +808,7 @@ type AS2ValidationSettings struct { CheckCertificateRevocationListOnSend *bool `json:"checkCertificateRevocationListOnSend,omitempty"` CheckCertificateRevocationListOnReceive *bool `json:"checkCertificateRevocationListOnReceive,omitempty"` EncryptionAlgorithm EncryptionAlgorithm `json:"encryptionAlgorithm,omitempty"` + SigningAlgorithm SigningAlgorithm `json:"signingAlgorithm,omitempty"` } // B2BPartnerContent is the B2B partner content. @@ -1434,6 +1460,11 @@ type RecurrenceScheduleOccurrence struct { Occurrence *int32 `json:"occurrence,omitempty"` } +// RegenerateActionParameter is the access key regenerate action content. +type RegenerateActionParameter struct { + KeyType KeyType `json:"keyType,omitempty"` +} + // Resource is the base resource type. type Resource struct { ID *string `json:"id,omitempty"` @@ -1450,6 +1481,16 @@ type ResourceReference struct { Type *string `json:"type,omitempty"` } +// RetryHistory is the retry history. +type RetryHistory struct { + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + Code *string `json:"code,omitempty"` + ClientRequestID *string `json:"clientRequestId,omitempty"` + ServiceRequestID *string `json:"serviceRequestId,omitempty"` + Error *ErrorResponse `json:"error,omitempty"` +} + // SetObject is type SetObject struct { autorest.Response `json:"-"` @@ -1587,6 +1628,7 @@ type WorkflowRunActionProperties struct { InputsLink *ContentLink `json:"inputsLink,omitempty"` OutputsLink *ContentLink `json:"outputsLink,omitempty"` TrackedProperties *map[string]interface{} `json:"trackedProperties,omitempty"` + RetryHistory *[]RetryHistory `json:"retryHistory,omitempty"` } // WorkflowRunFilter is the workflow run filter. @@ -1656,8 +1698,13 @@ type WorkflowTrigger struct { // WorkflowTriggerCallbackURL is the workflow trigger callback URL. type WorkflowTriggerCallbackURL struct { - autorest.Response `json:"-"` - Value *string `json:"value,omitempty"` + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` + Method *string `json:"method,omitempty"` + BasePath *string `json:"basePath,omitempty"` + RelativePath *string `json:"relativePath,omitempty"` + RelativePathParameters *[]string `json:"relativePathParameters,omitempty"` + Queries *WorkflowTriggerListCallbackURLQueries `json:"queries,omitempty"` } // WorkflowTriggerFilter is the workflow trigger filter. @@ -1713,6 +1760,15 @@ type WorkflowTriggerHistoryProperties struct { Run *ResourceReference `json:"run,omitempty"` } +// WorkflowTriggerListCallbackURLQueries is gets the workflow trigger callback +// URL query parameters. +type WorkflowTriggerListCallbackURLQueries struct { + APIVersion *string `json:"api-version,omitempty"` + Sp *string `json:"sp,omitempty"` + Sv *string `json:"sv,omitempty"` + Sig *string `json:"sig,omitempty"` +} + // WorkflowTriggerListResult is the list of workflow triggers. type WorkflowTriggerListResult struct { autorest.Response `json:"-"` diff --git a/arm/logic/partners.go b/arm/logic/partners.go index a617195a547d..f361cd2610ea 100755 --- a/arm/logic/partners.go +++ b/arm/logic/partners.go @@ -56,13 +56,15 @@ func (client PartnersClient) CreateOrUpdate(resourceGroupName string, integratio req, err := client.CreateOrUpdatePreparer(resourceGroupName, integrationAccountName, partnerName, partner) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -124,13 +126,15 @@ func (client PartnersClient) CreateOrUpdateResponder(resp *http.Response) (resul func (client PartnersClient) Delete(resourceGroupName string, integrationAccountName string, partnerName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, integrationAccountName, partnerName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -189,13 +193,15 @@ func (client PartnersClient) DeleteResponder(resp *http.Response) (result autore func (client PartnersClient) Get(resourceGroupName string, integrationAccountName string, partnerName string) (result IntegrationAccountPartner, err error) { req, err := client.GetPreparer(resourceGroupName, integrationAccountName, partnerName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -255,13 +261,15 @@ func (client PartnersClient) GetResponder(resp *http.Response) (result Integrati func (client PartnersClient) ListByIntegrationAccounts(resourceGroupName string, integrationAccountName string, top *int32, filter string) (result IntegrationAccountPartnerListResult, err error) { req, err := client.ListByIntegrationAccountsPreparer(resourceGroupName, integrationAccountName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + return } resp, err := client.ListByIntegrationAccountsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.PartnersClient", "ListByIntegrationAccounts", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.PartnersClient", "ListByIntegrationAccounts", resp, "Failure sending request") + return } result, err = client.ListByIntegrationAccountsResponder(resp) diff --git a/arm/logic/schemas.go b/arm/logic/schemas.go index 917ba92476fd..a5ad456b70af 100755 --- a/arm/logic/schemas.go +++ b/arm/logic/schemas.go @@ -54,13 +54,15 @@ func (client SchemasClient) CreateOrUpdate(resourceGroupName string, integration req, err := client.CreateOrUpdatePreparer(resourceGroupName, integrationAccountName, schemaName, schema) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -121,13 +123,15 @@ func (client SchemasClient) CreateOrUpdateResponder(resp *http.Response) (result func (client SchemasClient) Delete(resourceGroupName string, integrationAccountName string, schemaName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, integrationAccountName, schemaName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -185,13 +189,15 @@ func (client SchemasClient) DeleteResponder(resp *http.Response) (result autores func (client SchemasClient) Get(resourceGroupName string, integrationAccountName string, schemaName string) (result IntegrationAccountSchema, err error) { req, err := client.GetPreparer(resourceGroupName, integrationAccountName, schemaName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -251,13 +257,15 @@ func (client SchemasClient) GetResponder(resp *http.Response) (result Integratio func (client SchemasClient) ListByIntegrationAccounts(resourceGroupName string, integrationAccountName string, top *int32, filter string) (result IntegrationAccountSchemaListResult, err error) { req, err := client.ListByIntegrationAccountsPreparer(resourceGroupName, integrationAccountName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + return } resp, err := client.ListByIntegrationAccountsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.SchemasClient", "ListByIntegrationAccounts", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SchemasClient", "ListByIntegrationAccounts", resp, "Failure sending request") + return } result, err = client.ListByIntegrationAccountsResponder(resp) diff --git a/arm/logic/sessions.go b/arm/logic/sessions.go index 9223150f1b86..aa7cf6012316 100755 --- a/arm/logic/sessions.go +++ b/arm/logic/sessions.go @@ -55,13 +55,15 @@ func (client SessionsClient) CreateOrUpdate(resourceGroupName string, integratio req, err := client.CreateOrUpdatePreparer(resourceGroupName, integrationAccountName, sessionName, session) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -123,13 +125,15 @@ func (client SessionsClient) CreateOrUpdateResponder(resp *http.Response) (resul func (client SessionsClient) Delete(resourceGroupName string, integrationAccountName string, sessionName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, integrationAccountName, sessionName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -188,13 +192,15 @@ func (client SessionsClient) DeleteResponder(resp *http.Response) (result autore func (client SessionsClient) Get(resourceGroupName string, integrationAccountName string, sessionName string) (result IntegrationAccountSession, err error) { req, err := client.GetPreparer(resourceGroupName, integrationAccountName, sessionName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -254,13 +260,15 @@ func (client SessionsClient) GetResponder(resp *http.Response) (result Integrati func (client SessionsClient) ListByIntegrationAccounts(resourceGroupName string, integrationAccountName string, top *int32, filter string) (result IntegrationAccountSessionListResult, err error) { req, err := client.ListByIntegrationAccountsPreparer(resourceGroupName, integrationAccountName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "ListByIntegrationAccounts", nil, "Failure preparing request") + return } resp, err := client.ListByIntegrationAccountsSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.SessionsClient", "ListByIntegrationAccounts", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.SessionsClient", "ListByIntegrationAccounts", resp, "Failure sending request") + return } result, err = client.ListByIntegrationAccountsResponder(resp) diff --git a/arm/logic/version.go b/arm/logic/version.go index f92c18d9d4bb..a1e3ec821186 100755 --- a/arm/logic/version.go +++ b/arm/logic/version.go @@ -20,10 +20,10 @@ package logic // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v9.0.0-beta arm-logic/2016-06-01" + return "Azure-SDK-For-Go/v10.0.0-beta arm-logic/2016-06-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v9.0.0-beta" + return "v10.0.0-beta" } diff --git a/arm/logic/workflowrunactions.go b/arm/logic/workflowrunactions.go index 39b8daf10e52..e89d7c7f377b 100755 --- a/arm/logic/workflowrunactions.go +++ b/arm/logic/workflowrunactions.go @@ -49,13 +49,15 @@ func NewWorkflowRunActionsClientWithBaseURI(baseURI string, subscriptionID strin func (client WorkflowRunActionsClient) Get(resourceGroupName string, workflowName string, runName string, actionName string) (result WorkflowRunAction, err error) { req, err := client.GetPreparer(resourceGroupName, workflowName, runName, actionName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -116,13 +118,15 @@ func (client WorkflowRunActionsClient) GetResponder(resp *http.Response) (result func (client WorkflowRunActionsClient) List(resourceGroupName string, workflowName string, runName string, top *int32, filter string) (result WorkflowRunActionListResult, err error) { req, err := client.ListPreparer(resourceGroupName, workflowName, runName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunActionsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/logic/workflowruns.go b/arm/logic/workflowruns.go index f156b58b4e77..57b8959c843a 100755 --- a/arm/logic/workflowruns.go +++ b/arm/logic/workflowruns.go @@ -47,13 +47,15 @@ func NewWorkflowRunsClientWithBaseURI(baseURI string, subscriptionID string) Wor func (client WorkflowRunsClient) Cancel(resourceGroupName string, workflowName string, runName string) (result autorest.Response, err error) { req, err := client.CancelPreparer(resourceGroupName, workflowName, runName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Cancel", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Cancel", nil, "Failure preparing request") + return } resp, err := client.CancelSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Cancel", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Cancel", resp, "Failure sending request") + return } result, err = client.CancelResponder(resp) @@ -111,13 +113,15 @@ func (client WorkflowRunsClient) CancelResponder(resp *http.Response) (result au func (client WorkflowRunsClient) Get(resourceGroupName string, workflowName string, runName string) (result WorkflowRun, err error) { req, err := client.GetPreparer(resourceGroupName, workflowName, runName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -177,13 +181,15 @@ func (client WorkflowRunsClient) GetResponder(resp *http.Response) (result Workf func (client WorkflowRunsClient) List(resourceGroupName string, workflowName string, top *int32, filter string) (result WorkflowRunListResult, err error) { req, err := client.ListPreparer(resourceGroupName, workflowName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowRunsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) diff --git a/arm/logic/workflows.go b/arm/logic/workflows.go index 264bdf54e5ab..521a2d458cb1 100755 --- a/arm/logic/workflows.go +++ b/arm/logic/workflows.go @@ -47,13 +47,15 @@ func NewWorkflowsClientWithBaseURI(baseURI string, subscriptionID string) Workfl func (client WorkflowsClient) CreateOrUpdate(resourceGroupName string, workflowName string, workflow Workflow) (result Workflow, err error) { req, err := client.CreateOrUpdatePreparer(resourceGroupName, workflowName, workflow) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -113,13 +115,15 @@ func (client WorkflowsClient) CreateOrUpdateResponder(resp *http.Response) (resu func (client WorkflowsClient) Delete(resourceGroupName string, workflowName string) (result autorest.Response, err error) { req, err := client.DeletePreparer(resourceGroupName, workflowName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Delete", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Delete", nil, "Failure preparing request") + return } resp, err := client.DeleteSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Delete", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Delete", resp, "Failure sending request") + return } result, err = client.DeleteResponder(resp) @@ -176,13 +180,15 @@ func (client WorkflowsClient) DeleteResponder(resp *http.Response) (result autor func (client WorkflowsClient) Disable(resourceGroupName string, workflowName string) (result autorest.Response, err error) { req, err := client.DisablePreparer(resourceGroupName, workflowName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Disable", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Disable", nil, "Failure preparing request") + return } resp, err := client.DisableSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Disable", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Disable", resp, "Failure sending request") + return } result, err = client.DisableResponder(resp) @@ -239,13 +245,15 @@ func (client WorkflowsClient) DisableResponder(resp *http.Response) (result auto func (client WorkflowsClient) Enable(resourceGroupName string, workflowName string) (result autorest.Response, err error) { req, err := client.EnablePreparer(resourceGroupName, workflowName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Enable", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Enable", nil, "Failure preparing request") + return } resp, err := client.EnableSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Enable", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Enable", resp, "Failure sending request") + return } result, err = client.EnableResponder(resp) @@ -302,13 +310,15 @@ func (client WorkflowsClient) EnableResponder(resp *http.Response) (result autor func (client WorkflowsClient) GenerateUpgradedDefinition(resourceGroupName string, workflowName string, parameters GenerateUpgradedDefinitionParameters) (result SetObject, err error) { req, err := client.GenerateUpgradedDefinitionPreparer(resourceGroupName, workflowName, parameters) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "GenerateUpgradedDefinition", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "GenerateUpgradedDefinition", nil, "Failure preparing request") + return } resp, err := client.GenerateUpgradedDefinitionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "GenerateUpgradedDefinition", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "GenerateUpgradedDefinition", resp, "Failure sending request") + return } result, err = client.GenerateUpgradedDefinitionResponder(resp) @@ -368,13 +378,15 @@ func (client WorkflowsClient) GenerateUpgradedDefinitionResponder(resp *http.Res func (client WorkflowsClient) Get(resourceGroupName string, workflowName string) (result Workflow, err error) { req, err := client.GetPreparer(resourceGroupName, workflowName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -432,13 +444,15 @@ func (client WorkflowsClient) GetResponder(resp *http.Response) (result Workflow func (client WorkflowsClient) ListByResourceGroup(resourceGroupName string, top *int32, filter string) (result WorkflowListResult, err error) { req, err := client.ListByResourceGroupPreparer(resourceGroupName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListByResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListByResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListByResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListByResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListByResourceGroup", resp, "Failure sending request") + return } result, err = client.ListByResourceGroupResponder(resp) @@ -525,13 +539,15 @@ func (client WorkflowsClient) ListByResourceGroupNextResults(lastResults Workflo func (client WorkflowsClient) ListBySubscription(top *int32, filter string) (result WorkflowListResult, err error) { req, err := client.ListBySubscriptionPreparer(top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListBySubscription", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListBySubscription", nil, "Failure preparing request") + return } resp, err := client.ListBySubscriptionSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListBySubscription", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListBySubscription", resp, "Failure sending request") + return } result, err = client.ListBySubscriptionResponder(resp) @@ -610,6 +626,140 @@ func (client WorkflowsClient) ListBySubscriptionNextResults(lastResults Workflow return } +// ListSwagger gets an OpenAPI definition for the workflow. +// +// resourceGroupName is the resource group name. workflowName is the workflow +// name. +func (client WorkflowsClient) ListSwagger(resourceGroupName string, workflowName string) (result SetObject, err error) { + req, err := client.ListSwaggerPreparer(resourceGroupName, workflowName) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListSwagger", nil, "Failure preparing request") + return + } + + resp, err := client.ListSwaggerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListSwagger", resp, "Failure sending request") + return + } + + result, err = client.ListSwaggerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "ListSwagger", resp, "Failure responding to request") + } + + return +} + +// ListSwaggerPreparer prepares the ListSwagger request. +func (client WorkflowsClient) ListSwaggerPreparer(resourceGroupName string, workflowName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workflowName": autorest.Encode("path", workflowName), + } + + const APIVersion = "2016-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/listSwagger", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSwaggerSender sends the ListSwagger request. The method will close the +// http.Response Body if it receives an error. +func (client WorkflowsClient) ListSwaggerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListSwaggerResponder handles the response to the ListSwagger request. The method always +// closes the http.Response Body. +func (client WorkflowsClient) ListSwaggerResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateAccessKey regenerates the callback URL access key for request +// triggers. +// +// resourceGroupName is the resource group name. workflowName is the workflow +// name. keyType is the access key type. +func (client WorkflowsClient) RegenerateAccessKey(resourceGroupName string, workflowName string, keyType RegenerateActionParameter) (result autorest.Response, err error) { + req, err := client.RegenerateAccessKeyPreparer(resourceGroupName, workflowName, keyType) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "RegenerateAccessKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateAccessKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "RegenerateAccessKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateAccessKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "RegenerateAccessKey", resp, "Failure responding to request") + } + + return +} + +// RegenerateAccessKeyPreparer prepares the RegenerateAccessKey request. +func (client WorkflowsClient) RegenerateAccessKeyPreparer(resourceGroupName string, workflowName string, keyType RegenerateActionParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workflowName": autorest.Encode("path", workflowName), + } + + const APIVersion = "2016-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/regenerateAccessKey", pathParameters), + autorest.WithJSON(keyType), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// RegenerateAccessKeySender sends the RegenerateAccessKey request. The method will close the +// http.Response Body if it receives an error. +func (client WorkflowsClient) RegenerateAccessKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RegenerateAccessKeyResponder handles the response to the RegenerateAccessKey request. The method always +// closes the http.Response Body. +func (client WorkflowsClient) RegenerateAccessKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + // Update updates a workflow. // // resourceGroupName is the resource group name. workflowName is the workflow @@ -617,13 +767,15 @@ func (client WorkflowsClient) ListBySubscriptionNextResults(lastResults Workflow func (client WorkflowsClient) Update(resourceGroupName string, workflowName string, workflow Workflow) (result Workflow, err error) { req, err := client.UpdatePreparer(resourceGroupName, workflowName, workflow) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Update", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Update", nil, "Failure preparing request") + return } resp, err := client.UpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Update", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Update", resp, "Failure sending request") + return } result, err = client.UpdateResponder(resp) @@ -684,13 +836,15 @@ func (client WorkflowsClient) UpdateResponder(resp *http.Response) (result Workf func (client WorkflowsClient) Validate(resourceGroupName string, location string, workflowName string, workflow Workflow) (result autorest.Response, err error) { req, err := client.ValidatePreparer(resourceGroupName, location, workflowName, workflow) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Validate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Validate", nil, "Failure preparing request") + return } resp, err := client.ValidateSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Validate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowsClient", "Validate", resp, "Failure sending request") + return } result, err = client.ValidateResponder(resp) diff --git a/arm/logic/workflowtriggerhistories.go b/arm/logic/workflowtriggerhistories.go index 2bf8b452f85d..f83cf395e0aa 100755 --- a/arm/logic/workflowtriggerhistories.go +++ b/arm/logic/workflowtriggerhistories.go @@ -45,17 +45,20 @@ func NewWorkflowTriggerHistoriesClientWithBaseURI(baseURI string, subscriptionID // // resourceGroupName is the resource group name. workflowName is the workflow // name. triggerName is the workflow trigger name. historyName is the workflow -// trigger history name. +// trigger history name. Corresponds to the run name for triggers that resulted +// in a run. func (client WorkflowTriggerHistoriesClient) Get(resourceGroupName string, workflowName string, triggerName string, historyName string) (result WorkflowTriggerHistory, err error) { req, err := client.GetPreparer(resourceGroupName, workflowName, triggerName, historyName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -117,13 +120,15 @@ func (client WorkflowTriggerHistoriesClient) GetResponder(resp *http.Response) ( func (client WorkflowTriggerHistoriesClient) List(resourceGroupName string, workflowName string, triggerName string, top *int32, filter string) (result WorkflowTriggerHistoryListResult, err error) { req, err := client.ListPreparer(resourceGroupName, workflowName, triggerName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -204,3 +209,72 @@ func (client WorkflowTriggerHistoriesClient) ListNextResults(lastResults Workflo return } + +// Resubmit resubmits a workflow run based on the trigger history. +// +// resourceGroupName is the resource group name. workflowName is the workflow +// name. triggerName is the workflow trigger name. historyName is the workflow +// trigger history name. Corresponds to the run name for triggers that resulted +// in a run. +func (client WorkflowTriggerHistoriesClient) Resubmit(resourceGroupName string, workflowName string, triggerName string, historyName string) (result autorest.Response, err error) { + req, err := client.ResubmitPreparer(resourceGroupName, workflowName, triggerName, historyName) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "Resubmit", nil, "Failure preparing request") + return + } + + resp, err := client.ResubmitSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "Resubmit", resp, "Failure sending request") + return + } + + result, err = client.ResubmitResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggerHistoriesClient", "Resubmit", resp, "Failure responding to request") + } + + return +} + +// ResubmitPreparer prepares the Resubmit request. +func (client WorkflowTriggerHistoriesClient) ResubmitPreparer(resourceGroupName string, workflowName string, triggerName string, historyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "historyName": autorest.Encode("path", historyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + "workflowName": autorest.Encode("path", workflowName), + } + + const APIVersion = "2016-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/triggers/{triggerName}/histories/{historyName}/resubmit", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ResubmitSender sends the Resubmit request. The method will close the +// http.Response Body if it receives an error. +func (client WorkflowTriggerHistoriesClient) ResubmitSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ResubmitResponder handles the response to the Resubmit request. The method always +// closes the http.Response Body. +func (client WorkflowTriggerHistoriesClient) ResubmitResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/arm/logic/workflowtriggers.go b/arm/logic/workflowtriggers.go index ba30573a5deb..e374b14e9f3c 100755 --- a/arm/logic/workflowtriggers.go +++ b/arm/logic/workflowtriggers.go @@ -48,13 +48,15 @@ func NewWorkflowTriggersClientWithBaseURI(baseURI string, subscriptionID string) func (client WorkflowTriggersClient) Get(resourceGroupName string, workflowName string, triggerName string) (result WorkflowTrigger, err error) { req, err := client.GetPreparer(resourceGroupName, workflowName, triggerName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -114,13 +116,15 @@ func (client WorkflowTriggersClient) GetResponder(resp *http.Response) (result W func (client WorkflowTriggersClient) List(resourceGroupName string, workflowName string, top *int32, filter string) (result WorkflowTriggerListResult, err error) { req, err := client.ListPreparer(resourceGroupName, workflowName, top, filter) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -208,13 +212,15 @@ func (client WorkflowTriggersClient) ListNextResults(lastResults WorkflowTrigger func (client WorkflowTriggersClient) ListCallbackURL(resourceGroupName string, workflowName string, triggerName string) (result WorkflowTriggerCallbackURL, err error) { req, err := client.ListCallbackURLPreparer(resourceGroupName, workflowName, triggerName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "ListCallbackURL", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "ListCallbackURL", nil, "Failure preparing request") + return } resp, err := client.ListCallbackURLSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "ListCallbackURL", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "ListCallbackURL", resp, "Failure sending request") + return } result, err = client.ListCallbackURLResponder(resp) @@ -273,13 +279,15 @@ func (client WorkflowTriggersClient) ListCallbackURLResponder(resp *http.Respons func (client WorkflowTriggersClient) Run(resourceGroupName string, workflowName string, triggerName string) (result SetObject, err error) { req, err := client.RunPreparer(resourceGroupName, workflowName, triggerName) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Run", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Run", nil, "Failure preparing request") + return } resp, err := client.RunSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Run", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowTriggersClient", "Run", resp, "Failure sending request") + return } result, err = client.RunResponder(resp) diff --git a/arm/logic/workflowversions.go b/arm/logic/workflowversions.go index e0a00f3ad4d0..9db33e9b43fa 100755 --- a/arm/logic/workflowversions.go +++ b/arm/logic/workflowversions.go @@ -48,13 +48,15 @@ func NewWorkflowVersionsClientWithBaseURI(baseURI string, subscriptionID string) func (client WorkflowVersionsClient) Get(resourceGroupName string, workflowName string, versionID string) (result WorkflowVersion, err error) { req, err := client.GetPreparer(resourceGroupName, workflowName, versionID) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -113,13 +115,15 @@ func (client WorkflowVersionsClient) GetResponder(resp *http.Response) (result W func (client WorkflowVersionsClient) List(resourceGroupName string, workflowName string, top *int32) (result WorkflowVersionListResult, err error) { req, err := client.ListPreparer(resourceGroupName, workflowName, top) if err != nil { - return result, autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -196,3 +200,77 @@ func (client WorkflowVersionsClient) ListNextResults(lastResults WorkflowVersion return } + +// ListCallbackURL lists the callback URL for a trigger of a workflow version. +// +// resourceGroupName is the resource group name. workflowName is the workflow +// name. versionID is the workflow versionId. triggerName is the workflow +// trigger name. parameters is the callback URL parameters. +func (client WorkflowVersionsClient) ListCallbackURL(resourceGroupName string, workflowName string, versionID string, triggerName string, parameters *GetCallbackURLParameters) (result WorkflowTriggerCallbackURL, err error) { + req, err := client.ListCallbackURLPreparer(resourceGroupName, workflowName, versionID, triggerName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "ListCallbackURL", nil, "Failure preparing request") + return + } + + resp, err := client.ListCallbackURLSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "ListCallbackURL", resp, "Failure sending request") + return + } + + result, err = client.ListCallbackURLResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "logic.WorkflowVersionsClient", "ListCallbackURL", resp, "Failure responding to request") + } + + return +} + +// ListCallbackURLPreparer prepares the ListCallbackURL request. +func (client WorkflowVersionsClient) ListCallbackURLPreparer(resourceGroupName string, workflowName string, versionID string, triggerName string, parameters *GetCallbackURLParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + "versionId": autorest.Encode("path", versionID), + "workflowName": autorest.Encode("path", workflowName), + } + + const APIVersion = "2016-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/versions/{versionId}/triggers/{triggerName}/listCallbackUrl", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare(&http.Request{}) +} + +// ListCallbackURLSender sends the ListCallbackURL request. The method will close the +// http.Response Body if it receives an error. +func (client WorkflowVersionsClient) ListCallbackURLSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListCallbackURLResponder handles the response to the ListCallbackURL request. The method always +// closes the http.Response Body. +func (client WorkflowVersionsClient) ListCallbackURLResponder(resp *http.Response) (result WorkflowTriggerCallbackURL, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/arm/machinelearning/commitmentplans/client.go b/arm/machinelearning/commitmentplans/client.go index 6856f4e67c4f..c4d5300c8028 100644 --- a/arm/machinelearning/commitmentplans/client.go +++ b/arm/machinelearning/commitmentplans/client.go @@ -31,9 +31,6 @@ import ( ) const ( - // APIVersion is the version of the Commitmentplans - APIVersion = "2016-05-01-preview" - // DefaultBaseURI is the default URI used for the service Commitmentplans DefaultBaseURI = "https://management.azure.com" ) @@ -42,7 +39,6 @@ const ( type ManagementClient struct { autorest.Client BaseURI string - APIVersion string SubscriptionID string } @@ -56,7 +52,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, - APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/arm/machinelearning/commitmentplans/commitmentassociations.go b/arm/machinelearning/commitmentplans/commitmentassociations.go index c92eddcdd681..7e72a61034f4 100644 --- a/arm/machinelearning/commitmentplans/commitmentassociations.go +++ b/arm/machinelearning/commitmentplans/commitmentassociations.go @@ -54,13 +54,15 @@ func NewCommitmentAssociationsClientWithBaseURI(baseURI string, subscriptionID s func (client CommitmentAssociationsClient) Get(resourceGroupName string, commitmentPlanName string, commitmentAssociationName string) (result CommitmentAssociation, err error) { req, err := client.GetPreparer(resourceGroupName, commitmentPlanName, commitmentAssociationName) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -80,8 +82,9 @@ func (client CommitmentAssociationsClient) GetPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -119,13 +122,15 @@ func (client CommitmentAssociationsClient) GetResponder(resp *http.Response) (re func (client CommitmentAssociationsClient) List(resourceGroupName string, commitmentPlanName string, skipToken string) (result CommitmentAssociationListResult, err error) { req, err := client.ListPreparer(resourceGroupName, commitmentPlanName, skipToken) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -144,8 +149,9 @@ func (client CommitmentAssociationsClient) ListPreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(skipToken) > 0 { queryParameters["$skipToken"] = autorest.Encode("query", skipToken) @@ -210,13 +216,15 @@ func (client CommitmentAssociationsClient) ListNextResults(lastResults Commitmen func (client CommitmentAssociationsClient) Move(resourceGroupName string, commitmentPlanName string, commitmentAssociationName string, movePayload MoveCommitmentAssociationRequest) (result CommitmentAssociation, err error) { req, err := client.MovePreparer(resourceGroupName, commitmentPlanName, commitmentAssociationName, movePayload) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Move", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Move", nil, "Failure preparing request") + return } resp, err := client.MoveSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Move", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.CommitmentAssociationsClient", "Move", resp, "Failure sending request") + return } result, err = client.MoveResponder(resp) @@ -236,8 +244,9 @@ func (client CommitmentAssociationsClient) MovePreparer(resourceGroupName string "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/machinelearning/commitmentplans/commitmentplansgroup.go b/arm/machinelearning/commitmentplans/commitmentplansgroup.go index 88276fcfb5e8..d3ab0eb8840f 100644 --- a/arm/machinelearning/commitmentplans/commitmentplansgroup.go +++ b/arm/machinelearning/commitmentplans/commitmentplansgroup.go @@ -52,13 +52,15 @@ func NewGroupClientWithBaseURI(baseURI string, subscriptionID string) GroupClien func (client GroupClient) CreateOrUpdate(createOrUpdatePayload CommitmentPlan, resourceGroupName string, commitmentPlanName string) (result CommitmentPlan, err error) { req, err := client.CreateOrUpdatePreparer(createOrUpdatePayload, resourceGroupName, commitmentPlanName) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "CreateOrUpdate", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "CreateOrUpdate", nil, "Failure preparing request") + return } resp, err := client.CreateOrUpdateSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "CreateOrUpdate", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "CreateOrUpdate", resp, "Failure sending request") + return } result, err = client.CreateOrUpdateResponder(resp) @@ -77,8 +79,9 @@ func (client GroupClient) CreateOrUpdatePreparer(createOrUpdatePayload Commitmen "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -118,13 +121,15 @@ func (client GroupClient) CreateOrUpdateResponder(resp *http.Response) (result C func (client GroupClient) Get(resourceGroupName string, commitmentPlanName string) (result CommitmentPlan, err error) { req, err := client.GetPreparer(resourceGroupName, commitmentPlanName) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Get", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Get", nil, "Failure preparing request") + return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Get", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Get", resp, "Failure sending request") + return } result, err = client.GetResponder(resp) @@ -143,8 +148,9 @@ func (client GroupClient) GetPreparer(resourceGroupName string, commitmentPlanNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -180,13 +186,15 @@ func (client GroupClient) GetResponder(resp *http.Response) (result CommitmentPl func (client GroupClient) List(skipToken string) (result ListResult, err error) { req, err := client.ListPreparer(skipToken) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -203,8 +211,9 @@ func (client GroupClient) ListPreparer(skipToken string) (*http.Request, error) "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(skipToken) > 0 { queryParameters["$skipToken"] = autorest.Encode("query", skipToken) @@ -269,13 +278,15 @@ func (client GroupClient) ListNextResults(lastResults ListResult) (result ListRe func (client GroupClient) ListInResourceGroup(resourceGroupName string, skipToken string) (result ListResult, err error) { req, err := client.ListInResourceGroupPreparer(resourceGroupName, skipToken) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "ListInResourceGroup", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "ListInResourceGroup", nil, "Failure preparing request") + return } resp, err := client.ListInResourceGroupSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "ListInResourceGroup", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "ListInResourceGroup", resp, "Failure sending request") + return } result, err = client.ListInResourceGroupResponder(resp) @@ -293,8 +304,9 @@ func (client GroupClient) ListInResourceGroupPreparer(resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(skipToken) > 0 { queryParameters["$skipToken"] = autorest.Encode("query", skipToken) @@ -360,13 +372,15 @@ func (client GroupClient) ListInResourceGroupNextResults(lastResults ListResult) func (client GroupClient) Patch(patchPayload PatchPayload, resourceGroupName string, commitmentPlanName string) (result CommitmentPlan, err error) { req, err := client.PatchPreparer(patchPayload, resourceGroupName, commitmentPlanName) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Patch", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Patch", nil, "Failure preparing request") + return } resp, err := client.PatchSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Patch", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Patch", resp, "Failure sending request") + return } result, err = client.PatchResponder(resp) @@ -385,8 +399,9 @@ func (client GroupClient) PatchPreparer(patchPayload PatchPayload, resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( @@ -425,13 +440,15 @@ func (client GroupClient) PatchResponder(resp *http.Response) (result Commitment func (client GroupClient) Remove(resourceGroupName string, commitmentPlanName string) (result autorest.Response, err error) { req, err := client.RemovePreparer(resourceGroupName, commitmentPlanName) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Remove", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Remove", nil, "Failure preparing request") + return } resp, err := client.RemoveSender(req) if err != nil { result.Response = resp - return result, autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Remove", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.GroupClient", "Remove", resp, "Failure sending request") + return } result, err = client.RemoveResponder(resp) @@ -450,8 +467,9 @@ func (client GroupClient) RemovePreparer(resourceGroupName string, commitmentPla "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } preparer := autorest.CreatePreparer( diff --git a/arm/machinelearning/commitmentplans/usagehistory.go b/arm/machinelearning/commitmentplans/usagehistory.go index 1ace41d2aba5..3fa496d08aca 100644 --- a/arm/machinelearning/commitmentplans/usagehistory.go +++ b/arm/machinelearning/commitmentplans/usagehistory.go @@ -53,13 +53,15 @@ func NewUsageHistoryClientWithBaseURI(baseURI string, subscriptionID string) Usa func (client UsageHistoryClient) List(resourceGroupName string, commitmentPlanName string, skipToken string) (result PlanUsageHistoryListResult, err error) { req, err := client.ListPreparer(resourceGroupName, commitmentPlanName, skipToken) if err != nil { - return result, autorest.NewErrorWithError(err, "commitmentplans.UsageHistoryClient", "List", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "commitmentplans.UsageHistoryClient", "List", nil, "Failure preparing request") + return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "commitmentplans.UsageHistoryClient", "List", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "commitmentplans.UsageHistoryClient", "List", resp, "Failure sending request") + return } result, err = client.ListResponder(resp) @@ -78,8 +80,9 @@ func (client UsageHistoryClient) ListPreparer(resourceGroupName string, commitme "subscriptionId": autorest.Encode("path", client.SubscriptionID), } + const APIVersion = "2016-05-01-preview" queryParameters := map[string]interface{}{ - "api-version": client.APIVersion, + "api-version": APIVersion, } if len(skipToken) > 0 { queryParameters["$skipToken"] = autorest.Encode("query", skipToken) diff --git a/arm/machinelearning/commitmentplans/version.go b/arm/machinelearning/commitmentplans/version.go index 6b9010772be6..2f7ac932381f 100644 --- a/arm/machinelearning/commitmentplans/version.go +++ b/arm/machinelearning/commitmentplans/version.go @@ -18,43 +18,12 @@ package commitmentplans // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -import ( - "bytes" - "fmt" - "strings" -) - -const ( - major = "8" - minor = "1" - patch = "0" - tag = "beta" - userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" -) - -// cached results of UserAgent and Version to prevent repeated operations. -var ( - userAgent string - version string -) - // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - if userAgent == "" { - userAgent = fmt.Sprintf(userAgentFormat, Version(), "commitmentplans", "2016-05-01-preview") - } - return userAgent + return "Azure-SDK-For-Go/v10.0.0-beta arm-commitmentplans/2016-05-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - if version == "" { - versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) - if tag != "" { - versionBuilder.WriteRune('-') - versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) - } - version = string(versionBuilder.Bytes()) - } - return version + return "v10.0.0-beta" } diff --git a/arm/machinelearning/webservices/client.go b/arm/machinelearning/webservices/client.go index 82272be96370..24c7399fd7af 100755 --- a/arm/machinelearning/webservices/client.go +++ b/arm/machinelearning/webservices/client.go @@ -1,5 +1,5 @@ // Package webservices implements the Azure ARM Webservices service API version -// 2016-05-01-preview. +// 2017-01-01. // // These APIs allow end users to operate on Azure Machine Learning Web Services // resources. They support the following operations: