From 05e8b4be7c28b4d042203cfaf81f04bd86447161 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 6 Jan 2022 00:22:54 +0000 Subject: [PATCH] CodeGen from PR 17183 in Azure/azure-rest-api-specs CDS component type update - mismatch between swagger and code values (#17183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Hub Generated] Review request for Microsoft.CostManagement to add version preview/2020-12-01-preview (#13609) * Latest * Latest * Latest * Latest * Latest * Latest * Latest * Latest * Latest * Latest * Latest * FixS360 | Microsoft.Billing (#13771) * fixing billing accounts and operations * adding total count. * typo fix * fixing spell check and prettier * Vakuncha changingcsharpreadme (#13806) * Update readme.csharp.md * Update readme.csharp.md * [aks] fix vm size model and osDiskType description (#13763) * fix: agent pool vm size should be string, not enum * fix: osDiskType default description for >= 2020-11-01 * [Hub Generated] Review request for Microsoft.DocumentDB to add version preview/2021-03-01-preview (#13267) * init * fix format * sync * read only * fix sample * fix Co-authored-by: Teng Pan * storagesync readme t2 config (#13810) * storagesync readme t2 config * storagesync readme.python t2 config * Updated SAS swagger with latest changes. (#13439) * Fixed hostname in the Offazure swaggers. * added newest swagger from service repo. This contains PE changes too. * rewritten swagger changes on existing swagger * some fixes to swagger * added examples. * fixes * edit * edit. * fixes * minor fix * edit * edit * edited default api version tag * Dev weather microsoft.maps 1.0 (#13796) * Remove preview from Weather API, remove X-Publish, and convert X-ms-enum ModelAsString to true * Revert changes to package-lock.json * Fix spelling error * Adding Azure Object Anchors error codes for IngestionProperties (#13787) * Added Azure Object Anchors error code field to IngestionProperties * Fixed spacing in example * Moved changes to new version * Addressed version mismatch, spacing * Fixed versions on examples * Readonly error code * Seeing if readonly error code is breaking * Revert "Seeing if readonly error code is breaking" This reverts commit c0b16f07c4a46a07fc7831a1735bb290804242ea. * Model error code as string * Renamed examples to asset conversion nomenclature * Fixed rename issues * Fixed issue #9593 (#13262) * Fixed issue #9593 * Removed redundant PrivateEndpointConnectionProperties attribute * [Hub Generated] Review request for Microsoft.Consumption to add version stable/2019-05-01 (#13800) * Fixed Swagger Validation Errors * Fixed Model Validation * [Hub Generated] Review request for Microsoft.CostManagement to add version stable/2019-11-01 (#13788) * Fixed Swagger Validation Errors * Fixed Type * Fixed Type * Fixed Setting Properties * Fixed Punctuation * Removed Item * Added Items Properties * Fixed Required Property * azurestack wave4 t2 config (#13813) * Added Microsoft.AppConfiguration 2021-03-01-preview API version. (#13490) * Added Microsoft.AppConfiguration 2021-03-01-preview API version. * Add system metadata to tracked resources in "Microsoft.AppConfiguration". Updated ConfigurationStore to reference the common tracked resource type definition. * Added disableLocalAuth property. * Add new api version swagger to readme. * Added/updated examples and added suppressions for standardized APIs. * Fixed prettier. * Add missing property fileStorageSkuName into MySQL Flexible Server spec (#13693) * appplatform t2 readme config (#13829) * customproviders t2 readme config (#13831) * Update readme.csharp.md (#13807) * [Sentine][Data connectors][Fix correctness bug] (#13175) * update required fields * update required fields * Explicitly define KeyCreationTime in Feb21 (#13757) * Explicitly define KeyCreationTime Explicitly define KeyCreationTime * Fix KeyCreationTime Example Fix KeyCreationTime Example * Add Microsoft.M365SecurityAndCompliance RP (#13646) * Add Microsoft.M365SecurityAndCompliance RP * fix datetime and common-types file path * update common-types file path * add preview path in readmego * replace stable with preview * remove duplicate tags * refer MIPPolicySync json in readme * service name for java (#13837) * Dev keyvault microsoft.key vault 2021 04 01 preview (#13585) * Adds base for updating Microsoft.KeyVault from version preview/2020-04-01-preview to version 2021-04-01-preview * Updates readme * Updates API version in new specs and examples * Open API change for Managed Hsm private endpoints feature (#12938) * Open API change for Managed Hsm private endpoints feature * Fixing spell check errors * Fixing spell check errors * Prettier fixes * Fixing swagger validation errors * Fixing systemData property reference * Adding publicNetworkAccess property based on private endpoint requirement. * GET responses following a successful DELETE should be returning 404. … (#13054) * GET responses following a successful DELETE should be returning 404. Only the DELETE response is to return 204 if the resource didn't exist (it allows idempotent deletes). (cherry picked from commit b752a19c6cc1f8a8eed9f106e2c77b8d5b5db19f) * Removing 404 as it is taken care by default response. * Added new routes for Deleted ManagedHsm for Soft Delete Feature (#13282) * Added new routes for Deleted ManagedHsm and examples, updated ManagedHsm definition to include PurgeDateTimeUTC * Fixing validation issues. * Fixing errors in properties in example jsons * Delete keyvault.json Deleted an errant json file * Fixed misspelling of property in examples * Fixed x-ms-examples naming, fixed camelcasing * Addressing comments in PR to make 204s 404s and also changing PurgeDateTimeUTC to scheduledPurgeDate * Added schema definitions for 404 * Removed 200 for purge Co-authored-by: Soohwan Kim * Addressing Comments for PR 13585 (#13586) * Removed 404s to allow requests to fall through to default * Removing 404s from examples Co-authored-by: Soohwan Kim * Added deletedmanagedhsm object to examples and managedhsm.json (#13591) * Added deletedmanagedhsm object to examples and managedhsm.json * Fixing error in references to correct values * Changed vaultId to mhsmId in exmaples Co-authored-by: Soohwan Kim * Try to use the common type for SystemData (#13723) * Add SystemData property for KeyVault * 04012021 fix schema (#13749) * Resolving conflict with custom-words.txt * Add 2021 preview to azureresourcechema, add suppression to readme * Add 2021 preview to azureresourcechema * Merging custom-words.txt Co-authored-by: Soohwan Kim * Add missing default error response (#13762) * Fix Lint error (#13765) * Add missing default error response * Update the integer format to fix Lint error * Add securityDefinitions * Added python tag for 2021 preview (#13805) Co-authored-by: Soohwan Kim * Fixing linting errors for MHSM R4036 - ImplementPrivateEndpointAPIs (#13822) * Fixing linting errors for MHSM R4036 - ImplementPrivateEndpointAPIs (cherry picked from commit c1c5aebfb98cacd0a4ee5596fb7b0d9f782a9a3e) * prettier fix * Add suppression for SystemData (#13835) * Add suppression for SystemData * Fix linting error R4036 - ImplementPrivateEndpointAPIs * specify the suppression for SystemData * Revert "specify the suppression for SystemData" This reverts commit cbebab81ab08ec1a29b41c891c58cf08ff2eb3c4. Co-authored-by: jiacheng-L <71623842+jiacheng-L@users.noreply.github.com> Co-authored-by: kim-soohwan <40476315+kim-soohwan@users.noreply.github.com> Co-authored-by: Soohwan Kim Co-authored-by: Arthur Ning <57385816+akning-ms@users.noreply.github.com> * hybridnetwork only track2 configure (#13832) * hybridnetwork only track2 configure * remodify * namespace del Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) * terraform readme for alertsmanagement (#13744) Co-authored-by: Your Name * add tags back in the adp readme (#13850) * Add device principal type (#13799) * copy files from previous version * add device principal type, update versions * fix * system data requirement * Added CheckNameAvailability, Identity, systemData, used ErrorResponse v2 in DeviceUpdate (#13750) * Update deviceupdate.json * Update deviceupdate.json * Add files via upload * Update deviceupdate.json * Update deviceupdate.json * Update Accounts_Update.json * Update Accounts_Create.json * Update Instances_Create.json * Update deviceupdate.json * Linux line ending * Update CheckNameAvailability_AlreadyExists.json * Update CheckNameAvailability_Available.json * Update CheckNameAvailability_AlreadyExists.json * Update CheckNameAvailability_Available.json * Update CheckNameAvailability_AlreadyExists.json * Update CheckNameAvailability_Available.json * Update deviceupdate.json * Update deviceupdate.json * fixed typo in the example files (#13764) * Update CODEOWNERS (#13795) Updating list of Azure Cognitive Search team members * Update GenerateDetailedCostReportBySubscriptionAndTimePeriod.json (#13772) Update example data * [Hub Generated] Public private branch 'stuartko/Mar21_NewTSVersion' (#13811) * Adding version 2021-03-01-preview (copy of previous version) * Adding new metadata property * Adding uiDefinition property. * Update uiDefinition name to uiFormDefinition (per a change by the service feature author). No change to functionality. * Template Specs: Renaming template to "mainTemplate" and changing "artifacts" to be more specific "linkedTemplates". * Swagger changes for 2021-02-01-preview api version (#13794) * Copy existing preview version * Changes to databoxedge json file * Update readme files * Correct Spell Check * Fix Readme.go error * Update examples * Update all schemas.md files (#13862) * typo: implmentation -> implementation (#13644) * Add MongoDB/MongoDBAtlas sink (#13669) * Add MongoDB/MongoDBAtlas sink, add disableMetricsCollection in read/wirte properties * Revert disableMetricsCollection related changes * Azure ML new API version 20210401 (#12981) * Add Identity to createWorkpace example * change for getTransitivePEUsages * update * prettier code * add another new endpoint * address comments * change for getTransitivePEUsages * update * prettier code * add another new endpoint * address comments * revert change on transitivePE and notebookKeys * revert change on transitivePE and notebookKeys * add new stable version 2021-01-01 * add ListNotebookAccessToken * add primaryUserAssignedIdentity * fix missing properties and apis * fix one more missing property * 202 status for start and stop CI * make resync keys long runnin operation in version Jan2021 * resync keys 204 * update resync keys example * Dont throw 204 for resync * update resync keys * Formatting * revert Jan2021changes and add new version * start apr2021 version for azure ml rp * undo remove new line in jan2021 * use systemData definition in common * removed old files * fix small swagger bugs * run prettier * remove reference to sku * update readme * minimum agentCount should be 0 * add createdOn and ModifiedOn to compute properties * add LoadBalancerType to aks compute * add isNotebookInstanceCompute to virtualMachine * add leafDomainLabel to SslConfiguration * add overwriteExistingDomain to SslConfiguration * add synapseSpark as supported compute-type * update patch compute response to 202 * remove location from example responses * Revert "remove location from example responses" This reverts commit 048bf2551513afae842a9c4fbb5861aeddc6c33a. * MachineLearningCompute_Update should have a 200 response * sys data to use local def due to naming conflicts. * Fix enum casing * Fix operationId PR comment. * Change opId in apr version * remove 20210401 for easy review * only change api version * merge changes for 20210401 version * Add x-ms-discriminator-value for Synapse spark * camelcase loadbalancer properties * add createdOn and Modified on to examples * address AvoidAnonymousTypes error for SynapseSpark * Minor fixes + new property * Remove subscription state. Co-authored-by: zhaomuzhi Co-authored-by: Vinay Rajmal Soni Co-authored-by: jopet@microsoft.com Co-authored-by: Josh Peterson <15050193+joshanator@users.noreply.github.com> * datashare readme t2 config (#13833) * add readme terraform (#13717) * adding a new API version for Restore API and adding targetVirtualMachineId field for AzureWorkloadRestoreRequest (#13638) * copying previous change * Adding targetVirtualMachineId field for Azure Workload Restore requests * updating crr version and examples * removing new api-version * adding back the new api-version * removing Snapshot related fields * updating readme.md * corrected the path Co-authored-by: Chandrika Gonuguntla * chore: resort custom-words.txt from bad merge (#13868) * [ApplicationInsights] Fix failure for python SDK (#13875) * [Hub Generated] Review request for Microsoft.Insights to add version preview/2020-10-05-preview (#13712) * Adjustments to API to include validation grouping and updated text. * Fixed missing curly brace * adjusted name * Added basic and standard examples * adjusted type. * corrected case for key value * [Hub Generated] Review request for Microsoft.Insights to add version preview/2021-03-03-preview (#13269) * Adds base for updating Microsoft.Insights from version preview/2020-10-05-preview to version 2021-03-03-preview * Updates readme * Updates API version in new specs and examples * Add DiagnosticServiceToken API * Update examples to split tokens for readonly vs readwrite * Fix accoding to code review feedback * Update examples due to review feedback from ARM * add configuration for vmware (#13879) Co-authored-by: Your Name * keyvault t2 config (#13863) * keyvault t2 config * keyvault multi-api config * multi api config * config reset * add package version * hanaonazure t2 readme config (#13880) * Remove x-ms-azure-resource (#13500) Co-authored-by: Dongwei Wang * Juniwang/sr202010401preview (#13664) * prepare to add new api-version: copy everything from 2020-07-01-preview * Adding new api-version * Fix required body and annotate ms secrets * remove secrets example from swagger * fix prettier * add datashare terraform configuration (#13876) Co-authored-by: Your Name * storage readme t2 config (#13881) * storage readme t2 config * storage t2 config * healthcareapis t2 config (#13884) * typo: APIkeys -> APIKeys (#13641) * Allow release_policy to be nullable (#13826) * Fix type of Anserws and Captions (#13872) * change the value of license header (#13886) * [Synapse] - library_append API adds comp parameter (#13841) * [Synapse] - add comp parameter * Update example files Co-authored-by: Dongwei Wang * Remove 200 response from async operation (#13190) * Async operation always returns 202 on initial call * Address review feedback * Revert "Address review feedback" This reverts commit 9ae550b95c1082c8383595a943a9abe5990fd4ef. * add minimal tls version for mariadb (#11779) * [Synapse] - add Swagger code owner (#13882) Co-authored-by: Dongwei Wang * add con figuration for databoxedge (#13877) Co-authored-by: Your Name * add configuration for resourcemover (#13878) Co-authored-by: Your Name * Reduce code owner scope for Monitor.Exporters team (#13898) * [portal]Update readme.python.md (#13907) * Update readme.python.md * Update readme.md * Update readme.python.md * Update readme.python.md * Dev dfp microsoft.dfp 2021 02 01 privatepreview (#13305) * New Readme Config File * New Go Language Readme Config File * New Azure AZ Readme Config File * New Azure CLI Readme Config File * New Typescript Language Readme Config File * New Python Language Readme Config File * New C# Language Readme Config File * New AzureResourceSchema Readme Config File * New Swagger Spec File * New Swagger Example Spec File * DFP API specs. Copied from Azure-PPE * Spelling fix. instnace => instance * Fix resource provider name to pascal case * Added '/providers/Microsoft.Dfp/operations' * Added SystemData (fix R4009 error) * Fix validation errors * Prettier fixes * Removed non-existend parameter sku * Style fixes in DFP API specs * Swagger ModelValidation failures fix * Fix operations API * Fix operations API validation failure * 1. Added example for lists operations. 2. made the API preview instead of privatepreview * Fix path in readme's * Fix in readme * Added readonly attribute to systemdata * Added readonly attribute to systemdata * Fix in python SDK readme * Fixes in ListOperations.json examples * Fixed API version * Added type to response bodies * Fix typos in examples (urls) * Added 201 response into createInstance example * Renamed RP name from Microsoft.Dfp to Microsoft.Dynamics365Fraudprotection * Added long-running result for creation instance * Added nextlink * Fix in checkNameAvailability definition URL * Next link parameter * Using references to common types instead of re-declaring them * Reused common type. Fixed provisioning state * Nesting error fix * Fixed examples * Fix * Fix in error response definition * Rename RP. Fix examples in readme's * Added http 202 * Added http 202 to examples * [Hub Generated] Review request for Microsoft.InstanceMetadataService to add version stable/2020-10-01 (#13818) * Adds base for updating Microsoft.InstanceMetadataService from version stable/2020-09-01 to version 2020-10-01 * Updates readme * Updates API version in new specs and examples * Adding new fields for 2020-10-01 * Updating wording for disablePasswordAuthentication' Co-authored-by: jmccarthy * Remove name check from client side (#13492) * remove name validation from client side * remove name check from deploymentScripts swagger * remove name check from previous swagger versions * remove pattern from resourcegroupname parameter * Update deviceupdate.json (#13900) * [Hub Generated] Review request for Microsoft.ResourceHealth to add version stable/2018-07-01 (#13817) * Updated api-version * Removed systemData * Updated api-version * Updated the example * Add EligibleChildResources resource for PIM + update examples (#13803) * PIM API Specs * update readme * Update * Update readme * operation id fix * name fix * Name changes * fix * Fix * Changes based on docs generated * Scope fix in example * Updates for documentation * Change operation name * Update examples * Add expanded properties * Fix formatting * Fixes * Fix * fixes * Update the policy specs * Fix the policy objects and pell checks * fix the checks * fix the property * fix syntax * Prettier * Update Examples * Update Enums * ADd eligible child resource API specs * prettier fix * Update read me files * update * update * fix * update * Update Enums * update * update * update * update example Co-authored-by: Aman Swaika Co-authored-by: Gaurav Mishra (IDENTITY) * refine readme.go.md (#13906) Co-authored-by: Your Name * [Service Fabric Managed Clusters] adding api version 2020-05-01 (#13860) * initial commit 2021-05-01 to compare with previous version 2021-01-01-preview * update models * update examples * fix isStateless description * add 2021-05-01 version to readme * add x-ms-enum to diskType and add missing managedClsuterVersions paths fix example names add managed cluster version paths add default error * fix clusterversion by version and ClusterState descriptions Co-authored-by: Alfredo Santamaria Gomez * Task 9639284: Swagger changes for new UK agreement templates (#13895) * Task 9639284: Swagger changes for new UK agreement templates * Renamed as per comments. Co-authored-by: Umang Shah * Confluent new preview version + S360 fix (#13809) * Adding new API version for Microsoft.Confluent * Prettier fix * updated status property in OfferDetail updated status property in OfferDetail to fix swagger correctness issue * fix swagger live validation updated operations response to fix swagger live validation Co-authored-by: Srinivas * [Hub Generated] Public private branch 'juniwang/wps' (#13905) * Onboarding Azure WebPubSub service * reference ErrorResponse from common types and adding network ACL * disable cors, enable feature flags and fix several policy violations * remove anonymousConnectPolicy since it's not ready for now * add property publicNetworkAccess per NRP requirement * revert package-lock.json * reset package-lock.json * dns t2 readme config (#13923) * update readme (#13918) * add current readmes for generating python form recognizer (#12013) * add current readmes for python form recognizer * fix release tag * updates for multiapi and preview.3 * fix so that gen code outputs in generated folder * remove tag since swagger not in yet * unbreak build * just target preview 3 * don't run track 1 gen with python * Set x-ms-api-version to false for vaults list (#13924) * Set x-ms-api-version to false for vaults list (#13925) * Update event description to include the event name (#13867) * Update event description to include the event name * Update readme to include guidelines for defining a new event * Fix description * Renamed enum values for SDK auto generation (#13938) * Renamed enum values for SDK auto generation * Tabs to spaces * Newline added * [Document Translator] update operation names (#13915) * update operation names * make body required * Update ErrorName * Apply changes to stable * Fix samples * fix sample * Fix glossary sample * Address comments and update definitions names * Revert "Task 9639284: Swagger changes for new UK agreement templates (#13895)" (#13946) This reverts commit ea5bc27ee9cadeb67767d774c82095be2420bcad. * Adding new preview API for promotions (#11599) * Adding new preview API for promotions * Avacado fix * Fixing JSON * fixing the promo param * fixning linting issues * Fixing JSON * fixing JSON * fixing linting issues * Adding delete 204a * Adding delete 204 * Adding validation fixes * fixing spellings * Linting issues * running prettier * ARM review feedback * Fixing linting issues * Fixing prettier * Fixing version * Fixing SDK * fixing go sdk * revert go.md Co-authored-by: Rishi Kapoor * Exposing undocumented Databricks workspace properties for fixing S360 issues (#13683) * exposing storage account name, sku * Prettier fixes * Fixing the review comment * Adding No Public IP related properties * Updating the remaining properties related to S360 * Fixing review comments * Fixing Spell Check issue * hybridcompute readme t2 config (#13910) * readme t2 config * hybridcompute t2 readme config * web readme t2 config (#13909) * web readme t2 config * web readme.python t2 config * Add x-ms-api-version (#13834) * Update CheckNameAvailability_Available.json (#13914) * webpubsub t2 config (#13949) * Update StaticSite.json (#13768) * Update StaticSite.json Add private endpoint connections to static site object. * Update StaticSites.json * Update StaticSites.json * Update StaticSites.json * Update StaticSites.json * increment readme version * address PR comments * add examples * fix examples * Add data-plane samples creation template (#13528) * Add data-plane samples * Simplified template * webpubsub readme t1 del (#13953) * Add $(multiapi) to QnA Maker's readme.md (#13819) Generators were processing every tag when only a single one was desired. This is the common solution to support multi-api SDKs. * IoT data-plane for drwill-ms (#13964) * add missing usage.json to v5 sdk tag (#13960) * [Hub Generated] Review request for Microsoft.Kusto to add version stable/2021-01-01 (#13306) * Add new api version 2021 * remove managedIdentity since we won't support it in this version * CR comments * Add default value for contine on errros * Fix swagger correctness issues * Fix typo * resource t2 readme config (#13974) * Added new API and API version for private DNS zone suffix (#13789) * Added new API and API version for private DNS zone suffix * trigger validation pipelines * Add new API to readme * Fix ARM pipelines * Try fix again * Fix again * Add Operations API * Revert "Add Operations API" This reverts commit 9d4ca9e557763feb3a6089ff9d4c958b3843730e. * Revert "Revert "Add Operations API"" This reverts commit 7cf197c1d453764f0396713a2ab172a20e35b1c4. * Revert "Revert "Revert "Add Operations API""" This reverts commit 05744390e440984da8134b64a979a6e61fb9b7ae. * Revert "Revert "Revert "Revert "Add Operations API"""" This reverts commit 61b76b1623d9e5796bb8187edf0fc46351e78231. * Revert "Revert "Revert "Revert "Revert "Add Operations API""""" This reverts commit 9f55eb4c399eb48a8578906f6bea43b10c91b8be. * Address review comment from ARM * Revert "Address review comment from ARM" This reverts commit cb6d1b01860de72eec80856f64b602c72a1f26a7. * Revert "Revert "Address review comment from ARM"" This reverts commit 227cf73797ee24a674d76e3ccd2990b84bc8d11a. * Revert "Revert "Revert "Revert "Revert "Revert "Add Operations API"""""" This reverts commit 34ae6c70a514e0290ffb41f7ddb5bbbd5c6cbee3. * Revert "Revert "Revert "Revert "Revert "Revert "Revert "Add Operations API""""""" This reverts commit a11c889a65b0fa4257b03a247d75fbea769f4e2c. * Add previous APIs to tag * Retrigger build * fix service name for Java (#13979) * Add optional param - private DNS zone to server API (#13716) * Add optional param - private DNS zone to server API * Follow comment to resolve go sdk issue. * [Hub Generated] Review request for Microsoft.Synapse to add version preview/2021-04-01-preview (#13874) * Adds base for updating Microsoft.Synapse from version stable/2021-03-01 to version 2021-04-01-preview * Updates readme * Updates API version in new specs and examples * add changed files for kustoPool * Ravi changes to fix LinDiff validation * Add Itay Sofer's changes * filizt comments mid-way * Remove clouderror and resplace with "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" * Add IotHubDataConnection and EventGridDataConnection * Modify PUT to OK, CREATED, ACCEPTED * Change from provisioningState to ResourceProvisioningState * Add BlobStorageEventType * Remove 202 when creating a KustoPool * Change PUT/PATCH 202 responses * Remove 202 in PATCH/PUT operations where having both 200 & 201 * Add "isIdentityCertExprired" to custom-words.txt * Remove isIdentityCertExprired from custom-words.txt * Add Exprired to cSpell.json Co-authored-by: Amit Elran * Removing x-ms-flatten property (#13929) * manual changes for swagger * changes for long-running operations * changes for validate for backup and restore * removing 204 from operationResults * changes for a monitoring * adding format * removing date-time from duration * changing to readonly * changes for listRPs * fixes swagger * reverting readonly for scheduleTimes * fixes for checkgates * prettier fixes * cahnges for friendlyname checks * fixing gates * removing tracking-via * model validation fixes * powershell changes * adding stable version * changes for PatchResourceRequestInput * change for req fields * changes for description * changes * Updated swagger json for item level restore target info objects * Fixed spelling errors * Added missing required properties * removed auth credentials property * prettier fixes * Prettier fix * pr comments fixes * fixing readme * changes for go readme * Removed x-ms-flatten property (#2) * removed flatten prop * removing x-ms-flatten * removing friendlyName from req prop Co-authored-by: Mayank Aggarwal Co-authored-by: Mayank Aggarwal Co-authored-by: FAREAST\zakinkh * confidentialledger readme t2 config (#13981) * Additional 7.3-preview parameter name clean up (#13913) * Enable multivariate anomaly detection (#13973) * add multivarite * add v1.1-preview * reformat changepoint example * change typo in readme * fix prettier-check error * add export model example * fix prettier error * [Azure Search] Add Knowledge Store feature to swagger (#13911) * introduce knowledge store swagger * add knowledge store to 2020 apis Co-authored-by: Austin Drefke * make skillset count optional, and add it to 2020 GA Swagger (#13990) Co-authored-by: Austin Drefke * Adding support for message properties in ACS Chat (#13939) * Initial commit (copying over stable API version) * Making changes to support message metadata * Added 201 response code for patch operation (#13956) Co-authored-by: Akash Keshari * Adding autoMitigate flag with false as default value (#13109) * deploymentmanager - clean up duplicate parameters outside of method (#13948) * clean up duplicate parameters outside of method * maintain python order * fix typo in Synapse (#13994) * OperationalInsights - update readme files for cli extension update (#13999) * added3 new properties to TableProperties: IsTroubleshootingAllowed, IsTroubleshootingEnabled, IsTroubleshootingEnabledLastActivation. * added Tables new api version * changed bool to boolean types * prettified jsons * fix erroes in swagger * undo changes to 2020-03-01-preview version * pr fixes * updated TableUpdate example * changed lastTroubleshootDate from date format to string, removed isTroubleshootingAllowed from body of example * changed v1 to v2 * changed WorkspaceNameParameter back to V1 * changed ErrorResponse to default ErrorResponse without ref to local definition * added systemData * removed systemData * added systemData to Patch and Get * moved systemData to Table properties * deleted systemData from Table.json, added to Get and Put examles * changed location of systemData in Tables.json * moved systemData to inside Table definition * moved systemData inside Table properties * removed SystemData * creatted a new package containing all latest swagger files for publishing new SDK * removed package 2021_02 and set default packate to 2020_10 * removed 2 packages * removed DataCollectorLogs.json from readme.md 20202.10 * added empty line to try invoke pipeline validations that havent run * Delete Tables.json * added3 new properties to TableProperties: IsTroubleshootingAllowed, IsTroubleshootingEnabled, IsTroubleshootingEnabledLastActivation. * merge * prettified jsons * undo changes to 2020-03-01-preview version * updated TableUpdate example * changed lastTroubleshootDate from date format to string, removed isTroubleshootingAllowed from body of example * changed v1 to v2 * changed WorkspaceNameParameter back to V1 * added systemData * removed systemData * added systemData to Patch and Get * moved systemData to Table properties * deleted systemData from Table.json, added to Get and Put examles * changed location of systemData in Tables.json * moved systemData to inside Table definition * moved systemData inside Table properties * removed whitespaces * changed DataExportErrorResponse to common .../v2/types.json#/definitions/ErrorResponse * changed all Error response of 2020-08 to common definition * added readme.az.md file for cli extension code generator * added readme.ad.md with the same naming convention as in readme.python.md added readme.cli.md file updatted readme.md file with the new azure-cli-extensions tag all updates were done by following: https://github.com/Azure/autorest.az/blob/9ed1aabd353385f8bdffbfa9f3892478111a029c/doc/how-to-author-readme-file.md * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * Update specification/operationalinsights/resource-manager/readme.az.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * added azure-powershell to readme.md Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> * [Cognitive Services Metrics Advisor] add missing required for allOf entities (#13957) * add missing required for allOf entities * fix incorrect required properties * 7.2-Preview to GA (#13919) * 7.2-Preview to GA * Update packages to point to stable * Readd exportable and update description * Update description for exportable in preview versions * Fix operation results contract for Tenant Git operations (#13903) * fix operation results contract * fix sync state contract * iothub t2 readme config (#13980) * iothub t2 readme config * iothub readme t2 config * iothub t2 readme config * Making Offer details and User Details required properties (#13985) * Making Offer details and User Details required properties and removing abandoned tag * fix python configuration * Update readme.python.md Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> * cosmosdb t1 config del (#14008) * Fixing issue with missing filter documentation in Access Review APIs (#13892) * fix cred issue. block to merge in DSMainDev (#14014) * fix serivce name for java (#14007) * maintenance readme t2 config (#13982) * maintenance readme t2 config * readme t1 config * [Service Fabric Managed Clusters] fix api 2020_05_01 (#13961) * Use enums and add missing properties * model enum as string Co-authored-by: Alfredo Santamaria Gomez * [Hub Generated] Review request for Microsoft.BotService to add version stable/2021-03-01 (#13784) * add isIsolated and channelSchemaTransformationVersion * rename * add v2 priavatelinks (#14026) * copied from v1/privatelinks.json * bump version Co-authored-by: jianyexi * APIM: improve developer portal operations docs (#13941) * APIM: improve the documentation for dev portal operations * Minor changes * Removing OData parameters from the stable API version * Remove new query params * hotfix on extended location hierarchy (#13943) * [Hub Generated] Public private branch 'wps' (#14002) * Add webpubsub swagger Add custom words Update webpubsub.json Update webpubsub.json Resolve comments Update webpubsub.json resolve comments Update operationId for existence check [wps] update python generation section and client name for all languages (#1) * add python stuff * make title across languages the same * Update version * Update some constraints * Update webpubsub.json * rename to GetServiceStatus * Update readme.md * Update readme.md * Update readme.md * [Hub Generated] Review request for Microsoft.SecurityInsights to add version preview/2021-03-01-preview (#13563) * Copied from 2019-01-01-preview version * Updated references to common types * Add itemsSearchKey field to Watchlists * Add missing label definition * Make itemsSearchKey as required field * Formatting fixes * Fix Prettier and Avocado errors * Fix Lint error (subscription level resource) * Update description and example for CreateOrUpdate watchlists and bulk create watchlist items * Update Api version in examples * [Hub Generated] Review request for Microsoft.RecoveryServices to add version stable/2021-03-01 (#13888) * Adds base for updating Microsoft.RecoveryServices from version stable/2021-01-01 to version 2021-03-01 * Updates readme * Updates API version in new specs and examples * updated default package in readme.md to 2021-03 Co-authored-by: Chandrika Gonuguntla * Updated required and default fields in Action Groups spec (#13677) * Updated error response for Action Groups API * spacing * added missing fields to Action Group Resource spec * Added missing fields for action group resource in older version * Updated "resource" name * Removed changes to errorResponse * Removed errorObject * format * Updated required and default fields in Action groups spec * Update default value to boolean Co-authored-by: kai ru <69238381+kairu-ms@users.noreply.github.com> * changes default value type to boolean * undo webhook receiver changes Co-authored-by: Ritwik Rajendra Co-authored-by: kai ru <69238381+kairu-ms@users.noreply.github.com> * Remove AML Compute File Server (#13944) * Remove AML Compute File Server * update * update * update * update * Cost Management: Reservation Recommendations API: Add multiple missing properties in specs (#13967) * added totalCost, properties.resourceType, properties.subscriptionId, and eTag to various RiRec dfinitions * moving eTag property to right place * remove duplicate description * remove track1 configure (#14044) Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) * New API version (2021-02-10) for recovery services site recovery (#13525) * Adding old API version(2018-07-10) to new folder for 2021-20-10 * all changes for swagger (2021-02-10) * read me and custom word changes * Ayesha's comments addressed * adress PR comments from ayesha * Adding suppressions * fixing custom words * [Hub Generated] Review request for Microsoft.RecoveryServices to add version stable/2021-02-10 (#13636) * Adds base for updating Microsoft.RecoveryServices from version stable/2021-02-01 to version 2021-02-10 * Updates readme * Updates API version in new specs and examples * Update readme.md changing read me to include date too in tag * cahnging examples API version to 2021-02-10 * fix read me syntax * TaskStepProperties swagger fix (#13971) * Adding "assignmentState" property to scope model in access review APIs (#14039) * iothub readme.python package version change (#14043) * iothub readme.python package version change * multiapiscript add * clear output folder * Update readme.python.md * Update readme.python.md * Update readme.python.md Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> * Bump y18n from 4.0.0 to 4.0.1 (#13704) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update (#14061) * package-templatespecs-2021-03-preview tag added (python) (#13958) * Added tag * nit: ordering Co-authored-by: Dania Etienne * Use 2014-04-01 replication link specs in V5 SDK (#14058) * Use 2014-04-01 replication link specs in V5 SDK * remove legacy file. * Update cSpell.json for Key Vault 7.2 (storage) (#14060) * automanage readme t1 del (#14029) * automanage readme t1 del * automanage readme t1 del * readme.md t1 config del * add missing reference (#13904) * databoxedge readme modification (#14063) Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) * managedservices t2 onfig (#14064) Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) * [Hub Generated] Review request for Microsoft.RecoveryServices to add version stable/2021-02-10 (#13635) * Adds base for updating Microsoft.RecoveryServices from version stable/2021-01-01 to version 2021-02-10 * Updates readme * Updates API version in new specs and examples * fixing merge issue * removing vault usages from 2021-02 * Adding back vault usages * updating readme * updated etag to eTag (#13968) * [Hub Generated] Review request for Microsoft.InstanceMetadataService to add version stable/2020-12-01 (#13931) * Adds base for updating Microsoft.InstanceMetadataService from version stable/2020-10-01 to version 2020-12-01 * Updates readme * Updates API version in new specs and examples * Adding new spot VM fields Co-authored-by: Joshua McCarthy * Add FaceAPI PersonDirectory spec updates to preview v1.0 (#13766) * Add FaceAPI v1.0-preview Add a preview version of FaceAPI specs intended for public preview. Contains existing spec in v1.0 plus PersonDirectory feature changes. * Fixes after running validation * Fixing validation * Fixes 2 * Fixes 3 * Add PersonDirectory examples and fix routes * Fixes 4 * Fixes 5 * Fixes 5.5 Co-authored-by: Yang Chen * Update the name and format of a parameter for randomnumbers (#14017) * Update the name and format of a parameter for randomnumbers * Change the parameter name from 'bytes_length' back to 'bytesLength' * Amalladi/extendedlocation update (#13849) * Updating Specification to remove 400 Badrequest from Swagger File * Removing 400 status code from examples * Removing private preview API version from Repo * Removing 2020-07-15-privatepreview tag from ReadME files Co-authored-by: Aditi * maps t2 config (#14075) Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) * Revert "remove track1 configure (#14044)" (#14047) This reverts commit 867165cc24d81c487ad186c998c46ba55f81c77b. * adding role assignment (#14077) * add connectionPolicy spec back to V5 SDK (#14088) * modification (#14087) Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) * [Hub Generated] Review request for Microsoft.DocumentDB to add version preview/2021-04-01-preview (#13710) * Adds base for updating Microsoft.DocumentDB from version preview/2021-03-01-preview to version 2021-04-01-preview * Updates readme * Updates API version in new specs and examples * Adding new API for fetching backup information(such as latest restorable timestmap) for a resource. Also, adding startTime,endTime to restorable.json * Adding new API for fetching backup information(such as latest restorable timestmap) for a resource. Also, adding startTime,endTime to restorable.json * Adding new API for fetching backup information(such as latest restorable timestmap) for a resource. Also, adding startTime,endTime to restorable.json * adding Services APIs * more changes * updated examples * prettier and readme updates * importing changes missed from old versions * nits * fixing semantic validation * fixing linter * fix * more fixes * adding list operation and default error response * specifying format integer * attempt to fix sdks * address arm comments and fix ci * fixes * fix * try to fix ci * fix examples * .\services.json * adding additionalProperties back to ServiceResouce * adding additionalProperties back to ServiceResouce * fix * fix sdks * fix linter Co-authored-by: Meha Kaushik Co-authored-by: Meha Kaushik * media t2 config(wave4) (#14074) * media t2 config * add packageversion Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) * [Hub Generated] Review request for Microsoft.Maps to add version stable/2021-02-01 (#13733) * Adds base for updating Microsoft.Maps from version preview/2020-02-01-preview to version 2020-02-01 * Updates for 2021-02-01 api version swagger * creator swagger fixes * fix model examples * nextLink, uniqueId * build fixes * fixing listkeys * fix long running operations * fixing spelling * fixing async behavior and examples * updating arm region * reset package-lock * [Hub Generated] Review request for Microsoft.Media to add version preview/2021-05-01-preview (#13838) * New Readme Config File * New Go Language Readme Config File * New Azure AZ Readme Config File * New Azure CLI Readme Config File * New Typescript Language Readme Config File * New Python Language Readme Config File * New C# Language Readme Config File * New AzureResourceSchema Readme Config File * New Swagger Spec File * New Swagger Example Spec File * Copy Signed off 2021-03-01 swaggers here * Update swaggers to 2021=05-01-preview * add missing examples * update title * fix Operation id * fix video analyzer examples * update Video swagger * add format for $top * remove unnecessary example file * use chackname definitions from types.json * fix segment length readonly * change getStreamingToken to listStreamingToken, getProvisioningToken to listProvisioningToken * fix the example file name * fix a readonly issue with a video property * make type readonly * edits to descriptions * adding missing descriptions * address review feedback, * few cleanup for update class Co-authored-by: Christopher Bennage * Include the preview version of resource changes and resources history… (#14084) * Include the preview version of resource changes and resources history APIs * Address the review feedback on releasing the new package version. * Update readme for Synapse management SDK May release (#14054) * Update readme for Synapse management SDK May release * Add package-2021-05-preview * Address comment Co-authored-by: Dongwei Wang * removing read only property, no longer in use - NOT a breaking change (#13812) * resources readme.python t2 config (#14091) * peering readme t2 config (#14106) * Remove replicationLinks_legacy.json (#14095) PR #14058 removed this file: replicationLinks_legacy.json, removing from the schema config to prevent schema generation failures. * Support sheet index in excel (#14062) * Enable excel in public swagger * update * rollback dataflow change * Support sheet index in excel Co-authored-by: zhanyu2014 * Adding 2021-05-01 api-version to Template Specs (no changes over last preview spec) (#14065) * Copy existing 2021-03-01-preview specs to new 2021-05-01 stable version (no schema changes) * Changing api-version within specs to 2021-05-01 * Adding package tag for new stable version to readme.md, but not making it a default (yet) * Fix SecurityInsights Go SDK versioning (#14030) * Fix SecurityInsights Go SDK versioning * rename stable api version tag * remove 'only' from tags with full functionality * chore: Move typo supression in RecoveryServices (#14120) * Add missing Zone mapping property to Microsoft.Resources (#13936) * remove name validation from client side * remove name check from deploymentScripts swagger * remove name check from previous swagger versions * remove pattern from resourcegroupname parameter * add zoneMappings to ResoursesType * backfill older versions of swagger with zonemapping property * [Application Insights] Resolve duplicated definition names to fix track2 SDK generation error (#13951) * Fix duplicate name * Update readme.md * Update readme.md * Update and rename workbookOperations_API.json to aiOperations_API.json * Update readme.md * Update workbooks_API.json * Update readme.md * Update readme.python.md * Update readme.md * Update readme.md * Update readme.md * Rename aiOperations_API.json to workbookOperations_API.json * Update readme.md * Update readme.md * Update readme.md * Update readme.md * Update readme.md * Update readme.md * Update specification/applicationinsights/resource-manager/readme.python.md * Update specification/applicationinsights/resource-manager/readme.python.md * Update specification/applicationinsights/resource-manager/readme.python.md * Update swagger for SSIS-IR to support user-assigned managed identity (#14114) Co-authored-by: Hongxian Yao * postgresql readme t2 config (#14067) * Dev mediaservices microsoft.media 2021 05 01 (#13676) * Adds base for updating Microsoft.Media from version stable/2020-05-01 to version 2021-05-01 * Updates readme * Updates API version in new specs and examples * [AMS] new 2021-05-01 release for Account service in AMS * add missing example files * fix the api version and missing example files * Create a new Update definition to fix the "R2016 - PatchBodyParametersSchema " * fix respnse * fix update example * add the 2016 supression for new tag as well. * mixedreality t2 readme config(wave4) (#14105) * mixedreality t2 readme config * t2 config del * [python] t2-confidentialledger config (#14144) * Update readme.python.md * Update readme.python.md * Update readme.python.md (#14145) * update elastic swagger (#14076) * Update elastic.json * added new examples * taking the files from rpsaas master * added suppression in readme * [Cosmos DB] Introduce new api version 2021-04-15 (#13873) * [Cosmos DB] Introduce new api version 2021-04-15 Initial Commit * Updated for 2021-04-15 * Dummy Commit * Fixing privatelinkresources.json * Removing ErrorResponseUpdatedFormat * Suppressing systemData check * Relay - Fix typo in the NetworkRuleSet path (#13962) * Relay - Fix typo in the NetworkRuleSet path * Suppression - DefaultErrorResponseSchema - we will be Implementing in new API version * [Hub Generated] Review request for Microsoft.Portal to add version preview/2015-08-01-preview (#12732) * Fixing properties in dashboard parts * Updating Dashboard part metadata * Updating based on prettier fixes Co-authored-by: Himanshu Chandel * resources t1 config add (#14146) * t1 config add * package version * [Hub Generated] Public private branch 'dev-maintenance-Microsoft.Maintenance-2021-05-01' (#14148) * Adds base for updating Microsoft.Maintenance from version preview/2020-07-01-preview to version 2021-05-01 * Updates readme * Updates API version in new specs and examples * Added system data properties. * Fixed lint error. Added documentation. * Use Host Maintenance scope and api version in exmaple. Co-authored-by: Kalpesh Chavan * Add Test Base Swagger Spec from RPSaaSMaster (#14113) Co-authored-by: Bin Yu * rename property: change category to categories (#13883) * Edit description of Update Iot Hub Resource Api (#13080) Co-authored-by: Harini * [Hub Generated] Review request for Microsoft.RecoveryServices to add version stable/2021-03-01 (#13889) * Adds base for updating Microsoft.RecoveryServices from version stable/2018-07-10 to version 2021-03-01 * Updates readme * Updates API version in new specs and examples * Update webpubsub.json (#14096) * add dataFeedId in AnomalyResult and IncidentResult (#14127) * add dataFeedId in AnomalyResult and IncidentResult * fix examples * Add new version 2021-03-31-preview1 for ACS Auth (#13965) * Add new version 2021-03-31-preview * Set required body * Add all paths to new version * Update description for property of TeamsAccessTokenRequest model * Change version from 2021-03-31-preview to 2021-03-31-preview1 following standards https://skype.visualstudio.com/SPOOL/_wiki/wikis/SPOOL.wiki/16790/Versioning * Rename folder * Update method description * remove Turn endpoint * Add examples * Update readme * Omit the word "skypetoken" from swagger * Link example * Update description and path for a new endpoint Co-authored-by: Alexandra Lamiova Pistrakova * Added example gneration document links (#14151) * purview scanning service (#14021) * purview scanning service * Add custom words for spellcheck * fix config files and add endpoint param Co-authored-by: Parv Saxena Co-authored-by: iscai-msft * MG RP new API versions: 2020-10-01 and 2021-04-01 (#13897) * API 2020-10-01 with 2020-05-01 files * 2020-10-01 API changes * 2021-04-01 API version with 2020-10-01 files * Changes for 2021-04-01 API * PR fixes * Fixed issues with model * PR fixes * Latest (#13917) * Pick up previous Swagger Fix in 2019-09-01 version (#14092) * Add missing swagger fix * Fix bad copy-paste * update the some capitalized words in the description * Adding EventData schema for Microsoft.Storage.BlobTierChanged event (#14049) * Adding EventData schema for Microsoft.Storage.BlobTierChanged event * Removing contentLength/Offset from Microsoft.Storage.BlobTierChanged data schema * Removing BlobTierInfo from BlobTierChanged and adding new event Microsoft.Storage.AsyncOperationInitiated * adding ContentLength for BlobTierChanged and AsyncOperationInitiated events * [Hub Generated] Review request for VideoAnalyzer.Edge to add version preview/1.0.0 (#13682) * New Readme Config File * New Go Language Readme Config File * New Azure AZ Readme Config File * New Azure CLI Readme Config File * New Typescript Language Readme Config File * New Python Language Readme Config File * New C# Language Readme Config File * New AzureResourceSchema Readme Config File * New Swagger Spec File * New Swagger Example Spec File * Copy old LVA swaggers * Rename old swaggers to new file names * Update LVA swaggers with new AVA swagger * fixed some paths and capitalization * fix prettier check issues * fixing a Pascal casing * Updating swaggers to latest * fix linting issue * removed an unused definition * Service fabric Client API 8.0 (#14011) * spell checked and linted. * updated tag version. * reverted change outside of SF folder. * updated version in swagger. * changed credential issues. * changed 1 more that looks like a credential. * Kusto pools principal assignment (#14079) * kustoPool PrincipalAssignments * fixed list principal assignments * principalAssignment list example * principalAssignment get example * KustoPoolPrincipalAssignmentsCreateOrUpdate * KustoPoolPrincipalAssignmentsDelete * databases PrincipalAssignments * minor change * KustoPoolDatabasePrincipalAssignmentsList * KustoDatabasePrincipalAssignmentsGet * KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate * KustoPoolDatabasePrincipalAssignmentsDelete * fixed example ref * added system data * kustoPoolCheckNameAvailability * KustoPoolsCheckNameAvailability example Co-authored-by: Itay Sofer * [Service Fabric Managed Clusters] fix api 2021_01_01-preview (#14012) * Update preview api to disable broken properties and to add property that is working * Update managed cluster description * Add New Data Model RuleCollection to NetworkManager (#13827) * Add New Data Model RuleCollection to NetworkManager * fix typo * test * test * Fix discriminator * fix type * Fix discriminator * Fix type * fix type * Fix type * Fix discriminator * Fix discriminator * fix type * fix type * Fix bug * Fix type * Fix format * Fix name * Fix name * fix spell * fix description * Fix spell * change to kind * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * Fix post body * Fix as comments * fix bug * fix bug * fix bug * fix bug * fix bug * fix bug * change rule kind * Fix as comments * Fix as comments * update lastest version * Update type * Update Skiptoken * Fix discription * Fix NG * Fix NG * add more example * [python]Update readme.python.md for postgresql (#14182) * Update readme.python.md * Update readme.python.md * Remove all schema readme (#13885) * Remove all schema readme * process new rp * Remove after_scripts * [Hub Generated] Review request for Microsoft.AlertsManagement to add version stable/2021-04-01 (#13890) * Adds base for updating Microsoft.AlertsManagement from version stable/2019-06-01 to version 2021-04-01 * Updates readme * Updates API version in new specs and examples * first commit * some fixes * try without alert management * revert change to name of namespace * Resolve lintdiff issues * remove the copy of files and reference alert managment previous version * update description of subscriptionId to solve error * attemp to remove AlertsManagement from the package * revert (put back AlertsManagment) * add tags for go SDK release v54.0.0 (#14161) * add tags for go SDK release v54.0.0 * add a new tag * FRv2.1 GA Stable Release (#13997) * Standardized Errors, sample list. * removing from master from now as this is just a proposal * FRv2.1 GA Initial commit. Co-authored-by: Sandeep Parab * remove extra / from host template (#14176) * [Hub Generated] Review request for Microsoft.Batch to add version stable/2020-09-01.12.0 (#14170) * [Batch] Update RemoveNodes description to include max nodes/request * Added suppressions to readme * Update swagger for a new version 2021-03-31-preview1 for ACS Auth (#14168) * Unify names * Update tag * Update due to review meeting * update example description Co-authored-by: Alexandra Lamiova Pistrakova * Add new 1.0 version for IoT Central API (#13713) * Add new 1.0.0 version for IoT Central API * fix swagger style * fix wrong json file name * remove unused examples * revert back email format * remove non-used examples * update with latest examples * update preview from 2019-10-28-preview to 2021-04-30-preview * remove extra --- * update version from 1.0.0 to 1.0 * rollback collections for common entities * update _id to Id, update _name to Name from operation, add sdk generation * fix go sdk file * remove go sdk * updatedevicve_templateId to deviceTemplateId * Add query parameter based versioning, remove resource schema * fix example docs reference * fix typo in comments * renaming execute to run for command operations * add api-version to samples files, fix devices_update missining issue * add devices_update.json for 1.0 * fix rerun_id, add missing parameters to examples for preview, fix command comments from execute to run * fix annoymous type issues * add title to readme. (#14179) * videoanalyzers-fix-missing-host (#14181) * New API version for Microsoft.Resources stable/2021-04-01 (#14132) * base for Microsoft.Resources 2021-04-01 * update readme * update api version * API changes for S2S * readme Co-authored-by: Wendy Chang * Swagger Changes for Get Recoverable Servers and create server with Geo-Restore. (#14013) * Added Recoverable Servers API and GeoRestore API. * Fixed spell check and prettier * Fixed readme.md file issue and changed the postgreSQL to restore. * Fixed duplicate schema issue. * Fixed the mismatch with namespace names. * change the tag name from georestore to servers * Fixed the SDK validation issues. * Fixed objects w.r.t preview version * Fixed operation required properties. * Included 2020-04-10 in the SDK versions * Change the folder path. * Add missing multiapi entry for go sdk v54.0.0 release (#14200) * add missing multiapi entry * fix one output-folder * Azure security insights - add data connectors preview version (#13998) * add new API * ad name to enum * updatre defenition names * update readme * update readme * update readme path files * fix errors * add missing connectors * execute validation * execute pre * update readme * add description ans x-ms-enum * update description * update properties * add description * rename enum - fix new error that didnt display until now * rename enum unser x-ms-enum property * [Hub Generated] Review request for Microsoft.Maps/Alias to add version preview/2.0, preview/2.0, preview/2.0, preview/2.0, preview/2.0, preview/2.0 and preview/2.0 (#13921) * Copy Creator API 1.0 to 2.0 * draft of planB * adding ontology properties; adding DataUpload * updated alias apis * put v1 API back so diffing is easier * reapplying v2 so diffs are easier * remove type from datasetsources * incorporate suggestions from review board * adding ontology field * Update alias v2 apis. * fix conversion descriptions, update alias * Fix the alias file. * Add get details example. * fix casing on headers; mapData more consistent * minor comment and linting fixes * Adds base for updating Microsoft.Maps/Alias from version preview/1.0 to version 2.0 * Updates readme * Updates API version in new specs and examples * Add baseline from preview/1.0 * update api-version in examples * add v2 files to readme * fix avacado errors * Adding string length limit to the descriptions for feature state. Adding string length limit to the descriptions for feature state. * Adding ontology element to the WFS resopnse examples. Adding ontology element to the WFS resopnse examples. * Updating length to 1000 from 1024. Updating length to 1000 from 1024. * Update dataset v2 descriptions and examples. * Update the examples to have the right details. * reran linter; added spellcheck words * more linting: 202 description alignment * fixed example linting for alias, data, dataset * example linting changes for conv, fs, tileset * change featurestateset patch to put * autorest linting fixes * Reverting FeatureState body to include array to match V1 body and response. * adding missing operationIds * added examples; more linting * remove x-ms-long-running * Update alias documentation for resourceId -> creatorDataItemId change Co-authored-by: Robert Johnson Co-authored-by: Subbarayudu Kamma * Update attribute name for message metadata (#14206) * Update attribute name for message metadata * Apply Prettier * Prettier fix Co-authored-by: Po Tsang * Re-add a previously erroneously removed PUT API for /networkConfig/VirtualNetwork (#14018) * Add CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck, and site-level virtualNetworkSubnetId field * Add site-level virtualNetworkSubnetId field * Tabs vs spaces * Removing the new property since it's technically a 'breaking change' * Add changes needed for correct .NET SDK generation issues. Reference PR: https://github.com/Azure/azure-sdk-for-net/pull/20300 * Fix prettier issue. * Remove breaking changes other than property order changes * Make it pretty again * Added new properties SiteConfig.PublicNetworkAccess and Site.virtualNetworkSubnetId to enable azure policy * Fix prettier and spellcheck issue * Fix spellcheck issue * Add virtualNetworkSubnetId prperty to Site objec tmodel Co-authored-by: Naveed Aziz * Add Reading Order parameter to Computer Vision 3.2 Read Operation (#14204) * Fix CI for EG data-plane (#14171) * Fix CI for EG data-plane * Update readme.md * [Hub Generated] Review request for Microsoft.InstanceMetadataService to add version stable/2021-01-01 (#14130) * Adds base for updating Microsoft.InstanceMetadataService from version stable/2020-12-01 to version 2021-01-01 * Updates readme * Updates API version in new specs and examples * Adding user data flags * Wrong word Co-authored-by: jmccarthy * Balances API update (#14169) * Remove operationStatuses endpoint from Swagger (#14153) Co-authored-by: Ben Viglietta * Latest (#14173) * EventHub: Add Premium to EventHub SKU name and tier enums (#14046) Co-authored-by: v-ajnava * Add "fillGapWithZero" property to Microsoft.AppConfiguration/configurationStores (#14083) * add fillGapWithZero property * move new property to the end * removed the is read only from 4 features under OperationalInsights.Workspace * changed Tables.json to version 2020-08 due to AFEC flag blocking version 2020-10 * update enum to match values in the code Co-authored-by: Mel M <50640763+melmullen@users.noreply.github.com> Co-authored-by: Muaz Mian Co-authored-by: varun kumar kunchakuri <66476965+vakuncha@users.noreply.github.com> Co-authored-by: Ace Eldeib Co-authored-by: tengpanpt <68668066+tengpanpt@users.noreply.github.com> Co-authored-by: Teng Pan Co-authored-by: Zed Lei <59104634+RAY-316@users.noreply.github.com> Co-authored-by: kuchatur-ms <69152307+kuchatur-ms@users.noreply.github.com> Co-authored-by: jsedlak-microsoft <65620804+jsedlak-microsoft@users.noreply.github.com> Co-authored-by: jastenze <71854693+jastenze@users.noreply.github.com> Co-authored-by: Larry Osterman Co-authored-by: Omar Rodriguez <73562205+omrodrig@users.noreply.github.com> Co-authored-by: Jimmy Campbell Co-authored-by: Suna Liu Co-authored-by: sagamzu <52034287+sagamzu@users.noreply.github.com> Co-authored-by: Yihang Co-authored-by: sonalverm <73529783+sonalverm@users.noreply.github.com> Co-authored-by: Weidong Xu Co-authored-by: Ritesh chitlangia <60164879+riteshchitlangia1@users.noreply.github.com> Co-authored-by: jiacheng-L <71623842+jiacheng-L@users.noreply.github.com> Co-authored-by: kim-soohwan <40476315+kim-soohwan@users.noreply.github.com> Co-authored-by: Soohwan Kim Co-authored-by: Arthur Ning <57385816+akning-ms@users.noreply.github.com> Co-authored-by: zhangyan133 <77086185+zhangyan133@users.noreply.github.com> Co-authored-by: Yan Zhang (WICRESOFT NORTH AMERICA LTD) Co-authored-by: 陈箭飞 <32889038+chenjianfei2017@users.noreply.github.com> Co-authored-by: Your Name Co-authored-by: Cameron Taggart Co-authored-by: jdhms <77470403+jdhms@users.noreply.github.com> Co-authored-by: Alexander Batishchev Co-authored-by: dosegal <51155368+dosegal@users.noreply.github.com> Co-authored-by: Bruce Johnston Co-authored-by: Abdullah Syed <50675866+absyed@users.noreply.github.com> Co-authored-by: stuartko <47676853+stuartko@users.noreply.github.com> Co-authored-by: pvsraviteja <67624658+pvsraviteja@users.noreply.github.com> Co-authored-by: Lei Ni <7233663+leni-msft@users.noreply.github.com> Co-authored-by: Nick Schonning Co-authored-by: Guosen Wang Co-authored-by: Suba Co-authored-by: zhaomuzhi Co-authored-by: Vinay Rajmal Soni Co-authored-by: jopet@microsoft.com Co-authored-by: Josh Peterson <15050193+joshanator@users.noreply.github.com> Co-authored-by: chandrikagonuguntla Co-authored-by: Chandrika Gonuguntla Co-authored-by: kai ru <69238381+kairu-ms@users.noreply.github.com> Co-authored-by: aarongas Co-authored-by: Saar Shen Co-authored-by: Dongwei Wang Co-authored-by: Dongwei Wang Co-authored-by: Junbo Wang Co-authored-by: Hervey Wilson Co-authored-by: Janusz Lembicz Co-authored-by: Arcturus Co-authored-by: Alexander Schmidt Co-authored-by: ThomasDai <73230321+ThomasDai@users.noreply.github.com> Co-authored-by: Trask Stalnaker Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: alexsavo-ms <78455310+alexsavo-ms@users.noreply.github.com> Co-authored-by: Joshua McCarthy Co-authored-by: jmccarthy Co-authored-by: TJ Egbejimba Co-authored-by: averyrob <78236769+averyrob@users.noreply.github.com> Co-authored-by: Aman Swaika Co-authored-by: Aman Swaika Co-authored-by: Gaurav Mishra (IDENTITY) Co-authored-by: Alfredo Santamaria Co-authored-by: Alfredo Santamaria Gomez Co-authored-by: us6193 Co-authored-by: Umang Shah Co-authored-by: Krishna Sri Somepalli Co-authored-by: Srinivas Co-authored-by: Xiang Yan Co-authored-by: Krista Pratico Co-authored-by: Srikanta <51379715+srnagar@users.noreply.github.com> Co-authored-by: Jose Manuel Heredia Hidalgo Co-authored-by: rkapso Co-authored-by: Rishi Kapoor Co-authored-by: Subrahmanyam Mandavilli Co-authored-by: Xing Zhou Co-authored-by: mkarmark Co-authored-by: Laurent Mazuel Co-authored-by: Heath Stewart Co-authored-by: Ji Wang Co-authored-by: docohe <54349195+docohe@users.noreply.github.com> Co-authored-by: taogems <55105930+taogems@users.noreply.github.com> Co-authored-by: Amit Elran Co-authored-by: Amit Elran Co-authored-by: Mayank Aggarwal Co-authored-by: Mayank Aggarwal Co-authored-by: FAREAST\zakinkh Co-authored-by: Congrui <43364740+conhua@users.noreply.github.com> Co-authored-by: jadrefke Co-authored-by: Austin Drefke Co-authored-by: Amr Elroumy (Work) <77645021+amrelroumy-msft@users.noreply.github.com> Co-authored-by: akashkeshari Co-authored-by: Akash Keshari Co-authored-by: simanor <49607823+simanor@users.noreply.github.com> Co-authored-by: Tom FitzMacken Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> Co-authored-by: bowgong <56386108+bowgong@users.noreply.github.com> Co-authored-by: Jack Lichwa <52512203+jlichwa@users.noreply.github.com> Co-authored-by: Samir Solanki Co-authored-by: jainharsh98 Co-authored-by: Shubham Gupta Co-authored-by: ssss141414 Co-authored-by: JianyeXi <59603451+jianyexi@users.noreply.github.com> Co-authored-by: jianyexi Co-authored-by: Mike Budzynski <40186513+mikebudzynski@users.noreply.github.com> Co-authored-by: litchiyangMSFT <64560090+litchiyangMSFT@users.noreply.github.com> Co-authored-by: Liangying.Wei Co-authored-by: mayank88mahajan Co-authored-by: Ritwik Rajendra <21337621+ritwik8119@users.noreply.github.com> Co-authored-by: Ritwik Rajendra Co-authored-by: Weiguo Zhang Co-authored-by: maddieminn <79888413+maddieminn@users.noreply.github.com> Co-authored-by: nilgupta6 <78136736+nilgupta6@users.noreply.github.com> Co-authored-by: Yuan Xi Co-authored-by: Kai-Wen Feng <82062838+kaiwenfeng4086@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yuping Wei <56525716+yupwei68@users.noreply.github.com> Co-authored-by: Dania Etienne Co-authored-by: Dania Etienne Co-authored-by: msyache <70287970+msyache@users.noreply.github.com> Co-authored-by: Yang Chen Co-authored-by: yl-ms <79939366+yl-ms@users.noreply.github.com> Co-authored-by: Aditi <12823918+aditimalladi@users.noreply.github.com> Co-authored-by: Aditi Co-authored-by: Amit Singh <31076927+amisi01@users.noreply.github.com> Co-authored-by: Meha Kaushik Co-authored-by: Meha Kaushik Co-authored-by: Daniel Stack Co-authored-by: giakas Co-authored-by: Christopher Bennage Co-authored-by: Ramu Co-authored-by: vipinhas <82088177+vipinhas@users.noreply.github.com> Co-authored-by: Jorge Cotillo Co-authored-by: yuzhangyi <44692931+yuzhangyi@users.noreply.github.com> Co-authored-by: zhanyu2014 Co-authored-by: ityankel <47292630+ityankel@users.noreply.github.com> Co-authored-by: hongxian <48581117+hongxian@users.noreply.github.com> Co-authored-by: Hongxian Yao Co-authored-by: nichatur <69816349+nichatur@users.noreply.github.com> Co-authored-by: Ajit Navasare Co-authored-by: Himanshu Chandel Co-authored-by: Himanshu Chandel Co-authored-by: Kalpesh Chavan <18593210+KalpeshChavan12@users.noreply.github.com> Co-authored-by: Kalpesh Chavan Co-authored-by: Bin Yu <56588422+BinYuMSFT@users.noreply.github.com> Co-authored-by: Bin Yu Co-authored-by: bar810 Co-authored-by: harini-ms <34797776+harini-ms@users.noreply.github.com> Co-authored-by: Harini Co-authored-by: alexandra142 Co-authored-by: Alexandra Lamiova Pistrakova Co-authored-by: Ray Chen Co-authored-by: Parv Saxena Co-authored-by: Parv Saxena Co-authored-by: iscai-msft Co-authored-by: stivanov-git <61129265+stivanov-git@users.noreply.github.com> Co-authored-by: neku <82562198+Neku-microsoft@users.noreply.github.com> Co-authored-by: jeffj6123 Co-authored-by: ItaySofer Co-authored-by: Itay Sofer Co-authored-by: Luke Slevinsky Co-authored-by: yanfa317 <53584318+yanfa317@users.noreply.github.com> Co-authored-by: Noam Dishon <30979046+dishonono@users.noreply.github.com> Co-authored-by: sandeepparab Co-authored-by: Sandeep Parab Co-authored-by: kryalama <66494519+kryalama@users.noreply.github.com> Co-authored-by: David Watrous Co-authored-by: Johnson Yang Co-authored-by: wwendyc Co-authored-by: Wendy Chang Co-authored-by: Pradeep Kintali <50682039+pradeepkintali@users.noreply.github.com> Co-authored-by: Jeff Couckuyt Co-authored-by: Robert Johnson Co-authored-by: Subbarayudu Kamma Co-authored-by: xerxestph <78384060+xerxestph@users.noreply.github.com> Co-authored-by: Po Tsang Co-authored-by: aleksbol Co-authored-by: Naveed Aziz Co-authored-by: Thomas Reis Co-authored-by: Karthik Kunjithapatham <77180268+karthikku-2020@users.noreply.github.com> Co-authored-by: Ben Viglietta Co-authored-by: Ben Viglietta Co-authored-by: v-ajnava Co-authored-by: Shuai Wang --- .../azure-mgmt-applicationinsights/_meta.json | 10 +- ..._application_insights_management_client.py | 5 +- .../applicationinsights/_configuration.py | 4 +- ..._application_insights_management_client.py | 6 +- .../applicationinsights/aio/_configuration.py | 4 +- .../v2015_05_01/__init__.py | 9 +- ..._application_insights_management_client.py | 176 +- .../v2015_05_01/_configuration.py | 19 +- .../v2015_05_01/_metadata.json | 21 +- .../applicationinsights/v2015_05_01/_patch.py | 31 + .../v2015_05_01/_vendor.py | 27 + .../v2015_05_01/_version.py | 2 +- .../v2015_05_01/aio/__init__.py | 5 + ..._application_insights_management_client.py | 174 +- .../v2015_05_01/aio/_configuration.py | 6 +- .../v2015_05_01/aio/_patch.py | 31 + .../operations/_analytics_items_operations.py | 191 +- .../aio/operations/_annotations_operations.py | 176 +- .../aio/operations/_api_keys_operations.py | 167 +- ...component_available_features_operations.py | 42 +- ...ent_current_billing_features_operations.py | 87 +- ...mponent_feature_capabilities_operations.py | 42 +- .../_component_quota_status_operations.py | 42 +- .../aio/operations/_components_operations.py | 318 +-- .../_export_configurations_operations.py | 212 +- .../aio/operations/_favorites_operations.py | 209 +- .../operations/_my_workbooks_operations.py | 279 +- .../v2015_05_01/aio/operations/_operations.py | 47 +- ...ive_detection_configurations_operations.py | 134 +- .../_web_test_locations_operations.py | 62 +- .../aio/operations/_web_tests_operations.py | 287 +-- .../_work_item_configurations_operations.py | 244 +- .../aio/operations/_workbooks_operations.py | 216 +- .../v2015_05_01/models/__init__.py | 168 +- ...cation_insights_management_client_enums.py | 51 +- .../v2015_05_01/models/_models.py | 2272 ----------------- .../v2015_05_01/models/_models_py3.py | 1264 ++++++--- .../operations/_analytics_items_operations.py | 444 ++-- .../operations/_annotations_operations.py | 386 ++- .../operations/_api_keys_operations.py | 374 ++- ...component_available_features_operations.py | 98 +- ...ent_current_billing_features_operations.py | 199 +- ...mponent_feature_capabilities_operations.py | 98 +- .../_component_quota_status_operations.py | 98 +- .../operations/_components_operations.py | 701 +++-- .../_export_configurations_operations.py | 479 ++-- .../operations/_favorites_operations.py | 495 ++-- .../operations/_my_workbooks_operations.py | 595 +++-- .../v2015_05_01/operations/_operations.py | 88 +- ...ive_detection_configurations_operations.py | 298 ++- .../_web_test_locations_operations.py | 117 +- .../operations/_web_tests_operations.py | 611 +++-- .../_work_item_configurations_operations.py | 548 ++-- .../operations/_workbooks_operations.py | 481 ++-- .../v2017_10_01/__init__.py | 9 +- ..._application_insights_management_client.py | 107 +- .../v2017_10_01/_configuration.py | 19 +- .../v2017_10_01/_metadata.json | 21 +- .../applicationinsights/v2017_10_01/_patch.py | 31 + .../v2017_10_01/_vendor.py | 27 + .../v2017_10_01/_version.py | 2 +- .../v2017_10_01/aio/__init__.py | 5 + ..._application_insights_management_client.py | 93 +- .../v2017_10_01/aio/_configuration.py | 6 +- .../v2017_10_01/aio/_patch.py | 31 + ...mponent_current_pricing_plan_operations.py | 132 +- ...cription_list_migration_date_operations.py | 35 +- ...migrate_to_new_pricing_model_operations.py | 34 +- ...back_to_legacy_pricing_model_operations.py | 34 +- .../v2017_10_01/models/__init__.py | 15 +- .../v2017_10_01/models/_models.py | 165 -- .../v2017_10_01/models/_models_py3.py | 81 +- ...mponent_current_pricing_plan_operations.py | 299 ++- ...cription_list_migration_date_operations.py | 83 +- ...migrate_to_new_pricing_model_operations.py | 82 +- ...back_to_legacy_pricing_model_operations.py | 82 +- .../v2018_05_01_preview/__init__.py | 9 +- ..._application_insights_management_client.py | 98 +- .../v2018_05_01_preview/_configuration.py | 19 +- .../v2018_05_01_preview/_metadata.json | 21 +- .../v2018_05_01_preview/_patch.py | 31 + .../v2018_05_01_preview/_vendor.py | 27 + .../v2018_05_01_preview/_version.py | 2 +- .../v2018_05_01_preview/aio/__init__.py | 5 + ..._application_insights_management_client.py | 87 +- .../v2018_05_01_preview/aio/_configuration.py | 6 +- .../v2018_05_01_preview/aio/_patch.py | 31 + .../aio/operations/_components_operations.py | 318 +-- .../aio/operations/_operations.py | 48 +- ...ive_detection_configurations_operations.py | 134 +- .../aio/operations/_web_tests_operations.py | 287 +-- .../v2018_05_01_preview/models/__init__.py | 72 +- ...cation_insights_management_client_enums.py | 35 +- .../v2018_05_01_preview/models/_models.py | 961 ------- .../v2018_05_01_preview/models/_models_py3.py | 643 +++-- .../operations/_components_operations.py | 701 +++-- .../operations/_operations.py | 89 +- ...ive_detection_configurations_operations.py | 298 ++- .../operations/_web_tests_operations.py | 611 +++-- .../v2018_06_17_preview/__init__.py | 9 +- ..._application_insights_management_client.py | 82 +- .../v2018_06_17_preview/_configuration.py | 19 +- .../v2018_06_17_preview/_metadata.json | 21 +- .../v2018_06_17_preview/_patch.py | 31 + .../v2018_06_17_preview/_vendor.py | 27 + .../v2018_06_17_preview/_version.py | 2 +- .../v2018_06_17_preview/aio/__init__.py | 5 + ..._application_insights_management_client.py | 73 +- .../v2018_06_17_preview/aio/_configuration.py | 6 +- .../v2018_06_17_preview/aio/_patch.py | 31 + .../aio/operations/_operations.py | 47 +- .../aio/operations/_workbooks_operations.py | 236 +- .../v2018_06_17_preview/models/__init__.py | 33 +- ...cation_insights_management_client_enums.py | 23 +- .../v2018_06_17_preview/models/_models.py | 358 --- .../v2018_06_17_preview/models/_models_py3.py | 242 +- .../operations/_operations.py | 88 +- .../operations/_workbooks_operations.py | 513 ++-- .../v2019_10_17_preview/__init__.py | 9 +- ..._application_insights_management_client.py | 78 +- .../v2019_10_17_preview/_configuration.py | 19 +- .../v2019_10_17_preview/_metadata.json | 21 +- .../v2019_10_17_preview/_patch.py | 31 + .../v2019_10_17_preview/_vendor.py | 27 + .../v2019_10_17_preview/_version.py | 2 +- .../v2019_10_17_preview/aio/__init__.py | 5 + ..._application_insights_management_client.py | 66 +- .../v2019_10_17_preview/aio/_configuration.py | 6 +- .../v2019_10_17_preview/aio/_patch.py | 31 + .../_workbook_templates_operations.py | 218 +- .../v2019_10_17_preview/models/__init__.py | 27 +- .../v2019_10_17_preview/models/_models.py | 298 --- .../v2019_10_17_preview/models/_models_py3.py | 203 +- .../_workbook_templates_operations.py | 468 ++-- .../v2020_02_02_preview/__init__.py | 9 +- ..._application_insights_management_client.py | 78 +- .../v2020_02_02_preview/_configuration.py | 19 +- .../v2020_02_02_preview/_metadata.json | 21 +- .../v2020_02_02_preview/_patch.py | 31 + .../v2020_02_02_preview/_vendor.py | 27 + .../v2020_02_02_preview/_version.py | 2 +- .../v2020_02_02_preview/aio/__init__.py | 5 + ..._application_insights_management_client.py | 66 +- .../v2020_02_02_preview/aio/_configuration.py | 6 +- .../v2020_02_02_preview/aio/_patch.py | 31 + .../aio/operations/_components_operations.py | 336 ++- .../v2020_02_02_preview/models/__init__.py | 39 +- ...cation_insights_management_client_enums.py | 31 +- .../v2020_02_02_preview/models/_models.py | 534 ---- .../v2020_02_02_preview/models/_models_py3.py | 258 +- .../operations/_components_operations.py | 725 ++++-- .../v2020_03_01_preview/__init__.py | 9 +- ..._application_insights_management_client.py | 78 +- .../v2020_03_01_preview/_configuration.py | 19 +- .../v2020_03_01_preview/_metadata.json | 21 +- .../v2020_03_01_preview/_patch.py | 31 + .../v2020_03_01_preview/_vendor.py | 27 + .../v2020_03_01_preview/_version.py | 2 +- .../v2020_03_01_preview/aio/__init__.py | 5 + ..._application_insights_management_client.py | 66 +- .../v2020_03_01_preview/aio/_configuration.py | 6 +- .../v2020_03_01_preview/aio/_patch.py | 31 + ...nent_linked_storage_accounts_operations.py | 190 +- .../v2020_03_01_preview/models/__init__.py | 21 +- ...cation_insights_management_client_enums.py | 21 +- .../v2020_03_01_preview/models/_models.py | 189 -- .../v2020_03_01_preview/models/_models_py3.py | 32 +- ...nent_linked_storage_accounts_operations.py | 417 ++- .../v2020_06_02_preview/__init__.py | 9 +- ..._application_insights_management_client.py | 77 +- .../v2020_06_02_preview/_configuration.py | 17 +- .../v2020_06_02_preview/_metadata.json | 21 +- .../v2020_06_02_preview/_patch.py | 31 + .../v2020_06_02_preview/_vendor.py | 27 + .../v2020_06_02_preview/_version.py | 2 +- .../v2020_06_02_preview/aio/__init__.py | 5 + ..._application_insights_management_client.py | 70 +- .../v2020_06_02_preview/aio/_configuration.py | 6 +- .../v2020_06_02_preview/aio/_patch.py | 31 + .../aio/operations/_live_token_operations.py | 37 +- .../aio/operations/_operations.py | 48 +- .../v2020_06_02_preview/models/__init__.py | 21 +- .../v2020_06_02_preview/models/_models.py | 171 -- .../v2020_06_02_preview/models/_models_py3.py | 81 +- .../operations/_live_token_operations.py | 87 +- .../operations/_operations.py | 89 +- .../v2020_11_20/__init__.py | 9 +- ..._application_insights_management_client.py | 78 +- .../v2020_11_20/_configuration.py | 19 +- .../v2020_11_20/_metadata.json | 21 +- .../applicationinsights/v2020_11_20/_patch.py | 31 + .../v2020_11_20/_vendor.py | 27 + .../v2020_11_20/_version.py | 2 +- .../v2020_11_20/aio/__init__.py | 5 + ..._application_insights_management_client.py | 66 +- .../v2020_11_20/aio/_configuration.py | 6 +- .../v2020_11_20/aio/_patch.py | 31 + .../_workbook_templates_operations.py | 218 +- .../v2020_11_20/models/__init__.py | 30 +- .../v2020_11_20/models/_models.py | 317 --- .../v2020_11_20/models/_models_py3.py | 209 +- .../_workbook_templates_operations.py | 468 ++-- .../v2021_03_08/__init__.py | 9 +- ..._application_insights_management_client.py | 78 +- .../v2021_03_08/_configuration.py | 19 +- .../v2021_03_08/_metadata.json | 21 +- .../applicationinsights/v2021_03_08/_patch.py | 31 + .../v2021_03_08/_vendor.py | 27 + .../v2021_03_08/_version.py | 2 +- .../v2021_03_08/aio/__init__.py | 5 + ..._application_insights_management_client.py | 66 +- .../v2021_03_08/aio/_configuration.py | 6 +- .../v2021_03_08/aio/_patch.py | 31 + .../operations/_my_workbooks_operations.py | 301 +-- .../v2021_03_08/models/__init__.py | 30 +- ...cation_insights_management_client_enums.py | 27 +- .../v2021_03_08/models/_models.py | 351 --- .../v2021_03_08/models/_models_py3.py | 229 +- .../operations/_my_workbooks_operations.py | 632 +++-- .../v2021_08_01/__init__.py | 9 +- ..._application_insights_management_client.py | 75 +- .../v2021_08_01/_configuration.py | 19 +- .../v2021_08_01/_metadata.json | 21 +- .../applicationinsights/v2021_08_01/_patch.py | 31 + .../v2021_08_01/_vendor.py | 27 + .../v2021_08_01/_version.py | 2 +- .../v2021_08_01/aio/__init__.py | 5 + ..._application_insights_management_client.py | 66 +- .../v2021_08_01/aio/_configuration.py | 6 +- .../v2021_08_01/aio/_patch.py | 31 + .../aio/operations/_workbooks_operations.py | 383 ++- .../v2021_08_01/models/__init__.py | 42 +- ...cation_insights_management_client_enums.py | 29 +- .../v2021_08_01/models/_models.py | 582 ----- .../v2021_08_01/models/_models_py3.py | 303 ++- .../operations/_workbooks_operations.py | 806 ++++-- 236 files changed, 16233 insertions(+), 16250 deletions(-) create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_patch.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_vendor.py create mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_patch.py delete mode 100644 sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models.py diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json index 1f8a6dd954092..dcec14de7f8df 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "14aed8eee51e805ccf9a98c748ab31d798b2da2f", + "commit": "d3a252c22732198df4026f3498473724a1a06379", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/applicationinsights/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/applicationinsights/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/applicationinsights/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py index 985300ed598e3..d7d7d640f79b4 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_application_insights_management_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -92,12 +91,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ApplicationInsightsManagementClient, self).__init__( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py index b9fe819325a11..e4028eef846cc 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py index 888e309cc32dc..fe5936bec07da 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_application_insights_management_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -90,12 +90,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ApplicationInsightsManagementClient, self).__init__( diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py index 8fe81a741e697..ba2d2187ef45c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/aio/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py index f5d149778b32f..3dd8dc906ca8b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_application_insights_management_client.py @@ -6,153 +6,135 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import APIKeysOperations, AnalyticsItemsOperations, AnnotationsOperations, ComponentAvailableFeaturesOperations, ComponentCurrentBillingFeaturesOperations, ComponentFeatureCapabilitiesOperations, ComponentQuotaStatusOperations, ComponentsOperations, ExportConfigurationsOperations, FavoritesOperations, MyWorkbooksOperations, Operations, ProactiveDetectionConfigurationsOperations, WebTestLocationsOperations, WebTestsOperations, WorkItemConfigurationsOperations, WorkbooksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import Operations -from .operations import AnnotationsOperations -from .operations import APIKeysOperations -from .operations import ExportConfigurationsOperations -from .operations import ComponentCurrentBillingFeaturesOperations -from .operations import ComponentQuotaStatusOperations -from .operations import ComponentFeatureCapabilitiesOperations -from .operations import ComponentAvailableFeaturesOperations -from .operations import ProactiveDetectionConfigurationsOperations -from .operations import ComponentsOperations -from .operations import WorkItemConfigurationsOperations -from .operations import FavoritesOperations -from .operations import WebTestLocationsOperations -from .operations import WebTestsOperations -from .operations import AnalyticsItemsOperations -from .operations import WorkbooksOperations -from .operations import MyWorkbooksOperations -from . import models - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.applicationinsights.v2015_05_01.operations.Operations :ivar annotations: AnnotationsOperations operations - :vartype annotations: azure.mgmt.applicationinsights.v2015_05_01.operations.AnnotationsOperations + :vartype annotations: + azure.mgmt.applicationinsights.v2015_05_01.operations.AnnotationsOperations :ivar api_keys: APIKeysOperations operations :vartype api_keys: azure.mgmt.applicationinsights.v2015_05_01.operations.APIKeysOperations :ivar export_configurations: ExportConfigurationsOperations operations - :vartype export_configurations: azure.mgmt.applicationinsights.v2015_05_01.operations.ExportConfigurationsOperations + :vartype export_configurations: + azure.mgmt.applicationinsights.v2015_05_01.operations.ExportConfigurationsOperations :ivar component_current_billing_features: ComponentCurrentBillingFeaturesOperations operations - :vartype component_current_billing_features: azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentCurrentBillingFeaturesOperations + :vartype component_current_billing_features: + azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentCurrentBillingFeaturesOperations :ivar component_quota_status: ComponentQuotaStatusOperations operations - :vartype component_quota_status: azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentQuotaStatusOperations + :vartype component_quota_status: + azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentQuotaStatusOperations :ivar component_feature_capabilities: ComponentFeatureCapabilitiesOperations operations - :vartype component_feature_capabilities: azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentFeatureCapabilitiesOperations + :vartype component_feature_capabilities: + azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentFeatureCapabilitiesOperations :ivar component_available_features: ComponentAvailableFeaturesOperations operations - :vartype component_available_features: azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentAvailableFeaturesOperations + :vartype component_available_features: + azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentAvailableFeaturesOperations :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations - :vartype proactive_detection_configurations: azure.mgmt.applicationinsights.v2015_05_01.operations.ProactiveDetectionConfigurationsOperations + :vartype proactive_detection_configurations: + azure.mgmt.applicationinsights.v2015_05_01.operations.ProactiveDetectionConfigurationsOperations :ivar components: ComponentsOperations operations :vartype components: azure.mgmt.applicationinsights.v2015_05_01.operations.ComponentsOperations :ivar work_item_configurations: WorkItemConfigurationsOperations operations - :vartype work_item_configurations: azure.mgmt.applicationinsights.v2015_05_01.operations.WorkItemConfigurationsOperations + :vartype work_item_configurations: + azure.mgmt.applicationinsights.v2015_05_01.operations.WorkItemConfigurationsOperations :ivar favorites: FavoritesOperations operations :vartype favorites: azure.mgmt.applicationinsights.v2015_05_01.operations.FavoritesOperations :ivar web_test_locations: WebTestLocationsOperations operations - :vartype web_test_locations: azure.mgmt.applicationinsights.v2015_05_01.operations.WebTestLocationsOperations + :vartype web_test_locations: + azure.mgmt.applicationinsights.v2015_05_01.operations.WebTestLocationsOperations :ivar web_tests: WebTestsOperations operations :vartype web_tests: azure.mgmt.applicationinsights.v2015_05_01.operations.WebTestsOperations :ivar analytics_items: AnalyticsItemsOperations operations - :vartype analytics_items: azure.mgmt.applicationinsights.v2015_05_01.operations.AnalyticsItemsOperations + :vartype analytics_items: + azure.mgmt.applicationinsights.v2015_05_01.operations.AnalyticsItemsOperations :ivar workbooks: WorkbooksOperations operations :vartype workbooks: azure.mgmt.applicationinsights.v2015_05_01.operations.WorkbooksOperations :ivar my_workbooks: MyWorkbooksOperations operations - :vartype my_workbooks: azure.mgmt.applicationinsights.v2015_05_01.operations.MyWorkbooksOperations + :vartype my_workbooks: + azure.mgmt.applicationinsights.v2015_05_01.operations.MyWorkbooksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.annotations = AnnotationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_keys = APIKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.export_configurations = ExportConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_quota_status = ComponentQuotaStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_available_features = ComponentAvailableFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.components = ComponentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.work_item_configurations = WorkItemConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.favorites = FavoritesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.web_test_locations = WebTestLocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.web_tests = WebTestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.analytics_items = AnalyticsItemsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.my_workbooks = MyWorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.annotations = AnnotationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_configurations = ExportConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_quota_status = ComponentQuotaStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_available_features = ComponentAvailableFeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.work_item_configurations = WorkItemConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.favorites = FavoritesOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_test_locations = WebTestLocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.analytics_items = AnalyticsItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py index ade9b236d3617..238423fa73a30 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json index f261f1f3e347f..44c7919f3409f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py index 8f9350eeeb7c9..5d820c6671e12 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_application_insights_management_client.py @@ -6,149 +6,139 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import APIKeysOperations, AnalyticsItemsOperations, AnnotationsOperations, ComponentAvailableFeaturesOperations, ComponentCurrentBillingFeaturesOperations, ComponentFeatureCapabilitiesOperations, ComponentQuotaStatusOperations, ComponentsOperations, ExportConfigurationsOperations, FavoritesOperations, MyWorkbooksOperations, Operations, ProactiveDetectionConfigurationsOperations, WebTestLocationsOperations, WebTestsOperations, WorkItemConfigurationsOperations, WorkbooksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import Operations -from .operations import AnnotationsOperations -from .operations import APIKeysOperations -from .operations import ExportConfigurationsOperations -from .operations import ComponentCurrentBillingFeaturesOperations -from .operations import ComponentQuotaStatusOperations -from .operations import ComponentFeatureCapabilitiesOperations -from .operations import ComponentAvailableFeaturesOperations -from .operations import ProactiveDetectionConfigurationsOperations -from .operations import ComponentsOperations -from .operations import WorkItemConfigurationsOperations -from .operations import FavoritesOperations -from .operations import WebTestLocationsOperations -from .operations import WebTestsOperations -from .operations import AnalyticsItemsOperations -from .operations import WorkbooksOperations -from .operations import MyWorkbooksOperations -from .. import models - - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.Operations :ivar annotations: AnnotationsOperations operations - :vartype annotations: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.AnnotationsOperations + :vartype annotations: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.AnnotationsOperations :ivar api_keys: APIKeysOperations operations :vartype api_keys: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.APIKeysOperations :ivar export_configurations: ExportConfigurationsOperations operations - :vartype export_configurations: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ExportConfigurationsOperations + :vartype export_configurations: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ExportConfigurationsOperations :ivar component_current_billing_features: ComponentCurrentBillingFeaturesOperations operations - :vartype component_current_billing_features: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentCurrentBillingFeaturesOperations + :vartype component_current_billing_features: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentCurrentBillingFeaturesOperations :ivar component_quota_status: ComponentQuotaStatusOperations operations - :vartype component_quota_status: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentQuotaStatusOperations + :vartype component_quota_status: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentQuotaStatusOperations :ivar component_feature_capabilities: ComponentFeatureCapabilitiesOperations operations - :vartype component_feature_capabilities: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentFeatureCapabilitiesOperations + :vartype component_feature_capabilities: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentFeatureCapabilitiesOperations :ivar component_available_features: ComponentAvailableFeaturesOperations operations - :vartype component_available_features: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentAvailableFeaturesOperations + :vartype component_available_features: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentAvailableFeaturesOperations :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations - :vartype proactive_detection_configurations: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ProactiveDetectionConfigurationsOperations + :vartype proactive_detection_configurations: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ProactiveDetectionConfigurationsOperations :ivar components: ComponentsOperations operations - :vartype components: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentsOperations + :vartype components: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.ComponentsOperations :ivar work_item_configurations: WorkItemConfigurationsOperations operations - :vartype work_item_configurations: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WorkItemConfigurationsOperations + :vartype work_item_configurations: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WorkItemConfigurationsOperations :ivar favorites: FavoritesOperations operations - :vartype favorites: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.FavoritesOperations + :vartype favorites: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.FavoritesOperations :ivar web_test_locations: WebTestLocationsOperations operations - :vartype web_test_locations: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WebTestLocationsOperations + :vartype web_test_locations: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WebTestLocationsOperations :ivar web_tests: WebTestsOperations operations - :vartype web_tests: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WebTestsOperations + :vartype web_tests: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WebTestsOperations :ivar analytics_items: AnalyticsItemsOperations operations - :vartype analytics_items: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.AnalyticsItemsOperations + :vartype analytics_items: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.AnalyticsItemsOperations :ivar workbooks: WorkbooksOperations operations - :vartype workbooks: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WorkbooksOperations + :vartype workbooks: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.WorkbooksOperations :ivar my_workbooks: MyWorkbooksOperations operations - :vartype my_workbooks: azure.mgmt.applicationinsights.v2015_05_01.aio.operations.MyWorkbooksOperations + :vartype my_workbooks: + azure.mgmt.applicationinsights.v2015_05_01.aio.operations.MyWorkbooksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.annotations = AnnotationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_configurations = ExportConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_quota_status = ComponentQuotaStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_available_features = ComponentAvailableFeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.work_item_configurations = WorkItemConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.favorites = FavoritesOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_test_locations = WebTestLocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.analytics_items = AnalyticsItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.annotations = AnnotationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_keys = APIKeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.export_configurations = ExportConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_quota_status = ComponentQuotaStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_available_features = ComponentAvailableFeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.components = ComponentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.work_item_configurations = WorkItemConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.favorites = FavoritesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.web_test_locations = WebTestLocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.web_tests = WebTestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.analytics_items = AnalyticsItemsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.my_workbooks = MyWorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py index c18bcdbd24251..89eb5c7fc0c1b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py index b21b3f4fa4cc2..45fa16ef07b68 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_analytics_items_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._analytics_items_operations import build_delete_request, build_get_request, build_list_request, build_put_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -69,7 +74,8 @@ async def list( :type include_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentAnalyticsItem, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem] + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentAnalyticsItem"]] @@ -77,34 +83,21 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if scope is not None: - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - if type is not None: - query_parameters['type'] = self._serialize.query("type", type, 'str') - if include_content is not None: - query_parameters['includeContent'] = self._serialize.query("include_content", include_content, 'bool') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + scope=scope, + type=type, + include_content=include_content, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -118,8 +111,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,7 +140,8 @@ async def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAnalyticsItem, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAnalyticsItem"] @@ -152,32 +149,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if id is not None: - query_parameters['id'] = self._serialize.query("id", id, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + id=id, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,8 +176,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} # type: ignore + + @distributed_trace_async async def put( self, resource_group_name: str, @@ -213,13 +201,15 @@ async def put( :type scope_path: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScopePath :param item_properties: Properties that need to be specified to create a new item and add it to an Application Insights component. - :type item_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem + :type item_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :param override_item: Flag indicating whether or not to force save an item. This allows overriding an item if it already exists. :type override_item: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAnalyticsItem, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAnalyticsItem"] @@ -227,35 +217,24 @@ async def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if override_item is not None: - query_parameters['overrideItem'] = self._serialize.query("override_item", override_item, 'bool') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(item_properties, 'ApplicationInsightsComponentAnalyticsItem') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(item_properties, 'ApplicationInsightsComponentAnalyticsItem') + + request = build_put_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + content_type=content_type, + json=_json, + override_item=override_item, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,8 +248,11 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized + put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -303,30 +285,20 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if id is not None: - query_parameters['id'] = self._serialize.query("id", id, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + id=id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -338,3 +310,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py index 600ce0ee0f11b..6f31dbadb062a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_annotations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._annotations_operations import build_create_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -61,8 +67,10 @@ def list( :param end: The end time to query for annotations. :type end: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AnnotationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.AnnotationsListResult] + :return: An iterator like instance of either AnnotationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.AnnotationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AnnotationsListResult"] @@ -70,38 +78,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['start'] = self._serialize.query("start", start, 'str') - query_parameters['end'] = self._serialize.query("end", end, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + start=start, + end=end, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + start=start, + end=end, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AnnotationsListResult', pipeline_response) + deserialized = self._deserialize("AnnotationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,17 +121,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.AnnotationError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations'} # type: ignore + @distributed_trace_async async def create( self, resource_group_name: str, @@ -151,38 +160,28 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(annotation_properties, 'Annotation') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(annotation_properties, 'Annotation') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AnnotationError, response) + error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[Annotation]', pipeline_response) @@ -191,8 +190,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -219,26 +221,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'annotationId': self._serialize.url("annotation_id", annotation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + annotation_id=annotation_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -251,6 +245,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -277,34 +273,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'annotationId': self._serialize.url("annotation_id", annotation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + annotation_id=annotation_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AnnotationError, response) + error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[Annotation]', pipeline_response) @@ -313,4 +299,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py index a807fbf878cf7..8d735a4a1d6d1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_api_keys_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._api_keys_operations import build_create_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -54,8 +60,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentAPIKeyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKeyListResult] + :return: An iterator like instance of either ApplicationInsightsComponentAPIKeyListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKeyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAPIKeyListResult"] @@ -63,36 +71,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentAPIKeyListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKeyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,11 +115,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys'} # type: ignore + @distributed_trace_async async def create( self, resource_group_name: str, @@ -141,32 +148,22 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(api_key_properties, 'APIKeyRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(api_key_properties, 'APIKeyRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -180,8 +177,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -207,28 +207,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyId': self._serialize.url("key_id", key_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + key_id=key_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +232,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -269,28 +262,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyId': self._serialize.url("key_id", key_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + key_id=key_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -304,4 +287,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py index 2fbd6e862c6b1..d232727c338a5 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_available_features_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._component_available_features_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -54,7 +59,8 @@ async def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAvailableFeatures, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAvailableFeatures + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAvailableFeatures :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAvailableFeatures"] @@ -62,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,4 +92,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/getavailablebillingfeatures'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py index 2a50226aa6bab..8c3ec3ed4604d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_current_billing_features_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._component_current_billing_features_operations import build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -54,7 +59,8 @@ async def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentBillingFeatures, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentBillingFeatures"] @@ -62,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +92,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -113,10 +112,12 @@ async def update( :type resource_name: str :param billing_features_properties: Properties that need to be specified to update billing features for an Application Insights component. - :type billing_features_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures + :type billing_features_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentBillingFeatures, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentBillingFeatures"] @@ -124,32 +125,22 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(billing_features_properties, 'ApplicationInsightsComponentBillingFeatures') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(billing_features_properties, 'ApplicationInsightsComponentBillingFeatures') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,4 +154,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py index 4775c19811472..934fcd0fece80 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_feature_capabilities_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._component_feature_capabilities_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -54,7 +59,8 @@ async def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFeatureCapabilities, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeatureCapabilities + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeatureCapabilities :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentFeatureCapabilities"] @@ -62,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,4 +92,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/featurecapabilities'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py index f4edc267c8833..05e4ee934ceed 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_component_quota_status_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._component_quota_status_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -54,7 +59,8 @@ async def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentQuotaStatus, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentQuotaStatus + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentQuotaStatus :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentQuotaStatus"] @@ -62,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,4 +92,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py index 44467264da9db..dfb1f2b5d86e1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_components_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._components_operations import build_create_or_update_request, build_delete_request, build_get_purge_status_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_purge_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """Gets a list of all Application Insights components within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,11 +105,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -117,8 +122,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -126,35 +133,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,11 +175,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -199,25 +204,17 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -230,6 +227,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -252,27 +251,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -286,8 +275,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -304,7 +296,8 @@ async def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. - :type insight_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent + :type insight_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent @@ -315,32 +308,22 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -354,8 +337,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, @@ -381,32 +367,22 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(component_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(component_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -420,8 +396,11 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def purge( self, resource_group_name: str, @@ -454,32 +433,22 @@ async def purge( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.purge.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ComponentPurgeBody') + + request = build_purge_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.purge.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ComponentPurgeBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -493,8 +462,11 @@ async def purge( return cls(pipeline_response, deserialized, {}) return deserialized + purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'} # type: ignore + + @distributed_trace_async async def get_purge_status( self, resource_group_name: str, @@ -521,28 +493,18 @@ async def get_purge_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get_purge_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'purgeId': self._serialize.url("purge_id", purge_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_purge_status_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + purge_id=purge_id, + template_url=self.get_purge_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -556,4 +518,6 @@ async def get_purge_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py index cef95a38f88d7..6d5f38ec453c7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_export_configurations_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._export_configurations_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -53,8 +58,10 @@ async def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] + :return: list of ApplicationInsightsComponentExportConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentExportConfiguration"]] @@ -62,27 +69,17 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +93,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration'} # type: ignore + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -113,10 +113,13 @@ async def create( :type resource_name: str :param export_properties: Properties that need to be specified to create a Continuous Export configuration of a Application Insights component. - :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest + :type export_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] + :return: list of ApplicationInsightsComponentExportConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentExportConfiguration"]] @@ -124,32 +127,22 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') + + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,8 +156,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -183,7 +179,8 @@ async def delete( :type export_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentExportConfiguration"] @@ -191,28 +188,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'exportId': self._serialize.url("export_id", export_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + export_id=export_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -226,8 +213,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -246,7 +236,8 @@ async def get( :type export_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentExportConfiguration"] @@ -254,28 +245,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'exportId': self._serialize.url("export_id", export_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + export_id=export_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -289,8 +270,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -310,10 +294,12 @@ async def update( :type export_id: str :param export_properties: Properties that need to be specified to update the Continuous Export configuration. - :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest + :type export_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentExportConfiguration"] @@ -321,33 +307,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'exportId': self._serialize.url("export_id", export_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + export_id=export_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -361,4 +337,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py index 63f2ebdf032d2..7a827711a2dd0 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_favorites_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._favorites_operations import build_add_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -68,7 +73,8 @@ async def list( :type tags: list[str] :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentFavorite, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite] + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentFavorite"]] @@ -76,35 +82,21 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if favorite_type is not None: - query_parameters['favoriteType'] = self._serialize.query("favorite_type", favorite_type, 'str') - if source_type is not None: - query_parameters['sourceType'] = self._serialize.query("source_type", source_type, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_type=favorite_type, + source_type=source_type, + can_fetch_content=can_fetch_content, + tags=tags, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -118,8 +110,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -146,28 +141,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,8 +166,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + + @distributed_trace_async async def add( self, resource_group_name: str, @@ -202,7 +190,8 @@ async def add( :type favorite_id: str :param favorite_properties: Properties that need to be specified to create a new favorite and add it to an Application Insights component. - :type favorite_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite + :type favorite_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFavorite, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite @@ -213,33 +202,23 @@ async def add( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') + + request = build_add_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + content_type=content_type, + json=_json, + template_url=self.add.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -253,8 +232,11 @@ async def add( return cls(pipeline_response, deserialized, {}) return deserialized + add.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -274,7 +256,8 @@ async def update( :type favorite_id: str :param favorite_properties: Properties that need to be specified to update the existing favorite. - :type favorite_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite + :type favorite_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFavorite, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite @@ -285,33 +268,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -325,8 +298,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -353,26 +329,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -384,3 +352,4 @@ async def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py index 2b966e97d8a4b..03c596e638c6c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_my_workbooks_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._my_workbooks_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -61,8 +67,10 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -70,40 +78,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,17 +121,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace def list_by_subscription( self, category: Union[str, "_models.CategoryType"], @@ -144,8 +151,10 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -153,39 +162,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,17 +203,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -231,33 +238,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -266,8 +263,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -290,33 +290,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -324,6 +314,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -350,38 +342,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'MyWorkbook') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -394,8 +376,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -422,38 +407,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(workbook_properties, 'MyWorkbook') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -462,4 +437,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py index e79372b34e456..1299b38ea6c02 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py index b97a430c70a38..b371b79fea06c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_proactive_detection_configurations_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._proactive_detection_configurations_operations import build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -53,8 +58,10 @@ async def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration] + :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"]] @@ -62,27 +69,17 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +93,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -115,8 +115,10 @@ async def get( Application Insights component. :type configuration_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -124,28 +126,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,8 +151,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -180,10 +175,13 @@ async def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. - :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -191,33 +189,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -231,4 +219,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py index 5f8de9dca7876..0351081403e3c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_test_locations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._web_test_locations_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -54,8 +60,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsWebTestLocationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsWebTestLocationsListResult] + :return: An iterator like instance of either ApplicationInsightsWebTestLocationsListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsWebTestLocationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsWebTestLocationsListResult"] @@ -63,36 +71,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsWebTestLocationsListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsWebTestLocationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,6 +115,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py index 2895a1137f5b4..7f5f62a2b158e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_web_tests_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._web_tests_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_component_request, build_list_by_resource_group_request, build_list_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -52,7 +58,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -60,35 +67,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,11 +109,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -133,27 +138,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +162,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -195,32 +193,22 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(web_test_definition, 'WebTest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_definition, 'WebTest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,8 +222,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, @@ -261,32 +252,22 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(web_test_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -300,8 +281,11 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -324,25 +308,17 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + web_test_name=web_test_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -355,6 +331,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -363,7 +341,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -371,34 +350,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -416,11 +390,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace def list_by_component( self, component_name: str, @@ -435,7 +411,8 @@ def list_by_component( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -443,36 +420,33 @@ def list_by_component( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_component.metadata['url'] # type: ignore - path_format_arguments = { - 'componentName': self._serialize.url("component_name", component_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_component.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -490,6 +464,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py index 4bc9135d3f7f6..0c4f2715ac89e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_work_item_configurations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._work_item_configurations_operations import build_create_request, build_delete_request, build_get_default_request, build_get_item_request, build_list_request, build_update_item_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -54,8 +60,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkItemConfigurationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfigurationsListResult] + :return: An iterator like instance of either WorkItemConfigurationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfigurationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkItemConfigurationsListResult"] @@ -63,36 +71,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkItemConfigurationsListResult', pipeline_response) + deserialized = self._deserialize("WorkItemConfigurationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,17 +110,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkItemConfigurationError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkItemConfigurationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs'} # type: ignore + @distributed_trace_async async def create( self, resource_group_name: str, @@ -131,7 +138,8 @@ async def create( :type resource_name: str :param work_item_configuration_properties: Properties that need to be specified to create a work item configuration of a Application Insights component. - :type work_item_configuration_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration @@ -142,32 +150,22 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') + + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -181,8 +179,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs'} # type: ignore + + @distributed_trace_async async def get_default( self, resource_group_name: str, @@ -205,27 +206,17 @@ async def get_default( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get_default.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_default_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get_default.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -239,8 +230,11 @@ async def get_default( return cls(pipeline_response, deserialized, {}) return deserialized + get_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -267,26 +261,18 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'workItemConfigId': self._serialize.url("work_item_config_id", work_item_config_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -299,6 +285,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}'} # type: ignore + + @distributed_trace_async async def get_item( self, resource_group_name: str, @@ -325,28 +313,18 @@ async def get_item( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get_item.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'workItemConfigId': self._serialize.url("work_item_config_id", work_item_config_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_item_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + template_url=self.get_item.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -360,8 +338,11 @@ async def get_item( return cls(pipeline_response, deserialized, {}) return deserialized + get_item.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}'} # type: ignore + + @distributed_trace_async async def update_item( self, resource_group_name: str, @@ -381,7 +362,8 @@ async def update_item( :type work_item_config_id: str :param work_item_configuration_properties: Properties that need to be specified to update a work item configuration for this Application Insights component. - :type work_item_configuration_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration @@ -392,33 +374,23 @@ async def update_item( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_item.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'workItemConfigId': self._serialize.url("work_item_config_id", work_item_config_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') + + request = build_update_item_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + content_type=content_type, + json=_json, + template_url=self.update_item.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -432,4 +404,6 @@ async def update_item( return cls(pipeline_response, deserialized, {}) return deserialized + update_item.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py index 6772949a08e42..93c2ac5fe1243 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/aio/operations/_workbooks_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._workbooks_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -62,7 +68,8 @@ def list_by_resource_group( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkbooksListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -70,40 +77,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,17 +120,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -149,33 +155,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -184,8 +180,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -208,33 +207,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -242,6 +231,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -267,38 +258,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(workbook_properties, 'Workbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -311,8 +292,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -338,38 +322,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'Workbook') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -378,4 +352,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py index e060190841da0..329547518ceb3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/__init__.py @@ -6,118 +6,62 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import APIKeyRequest - from ._models_py3 import Annotation - from ._models_py3 import AnnotationError - from ._models_py3 import AnnotationsListResult - from ._models_py3 import ApplicationInsightsComponent - from ._models_py3 import ApplicationInsightsComponentAPIKey - from ._models_py3 import ApplicationInsightsComponentAPIKeyListResult - from ._models_py3 import ApplicationInsightsComponentAnalyticsItem - from ._models_py3 import ApplicationInsightsComponentAnalyticsItemProperties - from ._models_py3 import ApplicationInsightsComponentAvailableFeatures - from ._models_py3 import ApplicationInsightsComponentBillingFeatures - from ._models_py3 import ApplicationInsightsComponentDataVolumeCap - from ._models_py3 import ApplicationInsightsComponentExportConfiguration - from ._models_py3 import ApplicationInsightsComponentExportRequest - from ._models_py3 import ApplicationInsightsComponentFavorite - from ._models_py3 import ApplicationInsightsComponentFeature - from ._models_py3 import ApplicationInsightsComponentFeatureCapabilities - from ._models_py3 import ApplicationInsightsComponentFeatureCapability - from ._models_py3 import ApplicationInsightsComponentListResult - from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfiguration - from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions - from ._models_py3 import ApplicationInsightsComponentQuotaStatus - from ._models_py3 import ApplicationInsightsComponentWebTestLocation - from ._models_py3 import ApplicationInsightsWebTestLocationsListResult - from ._models_py3 import ComponentPurgeBody - from ._models_py3 import ComponentPurgeBodyFilters - from ._models_py3 import ComponentPurgeResponse - from ._models_py3 import ComponentPurgeStatusResponse - from ._models_py3 import ComponentsResource - from ._models_py3 import ErrorFieldContract - from ._models_py3 import ErrorResponse - from ._models_py3 import InnerError - from ._models_py3 import LinkProperties - from ._models_py3 import MyWorkbook - from ._models_py3 import MyWorkbookError - from ._models_py3 import MyWorkbookResource - from ._models_py3 import MyWorkbooksListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateLinkScopedResource - from ._models_py3 import TagsResource - from ._models_py3 import WebTest - from ._models_py3 import WebTestGeolocation - from ._models_py3 import WebTestListResult - from ._models_py3 import WebTestPropertiesConfiguration - from ._models_py3 import WebtestsResource - from ._models_py3 import WorkItemConfiguration - from ._models_py3 import WorkItemConfigurationError - from ._models_py3 import WorkItemConfigurationsListResult - from ._models_py3 import WorkItemCreateConfiguration - from ._models_py3 import Workbook - from ._models_py3 import WorkbookError - from ._models_py3 import WorkbookResource - from ._models_py3 import WorkbooksListResult -except (SyntaxError, ImportError): - from ._models import APIKeyRequest # type: ignore - from ._models import Annotation # type: ignore - from ._models import AnnotationError # type: ignore - from ._models import AnnotationsListResult # type: ignore - from ._models import ApplicationInsightsComponent # type: ignore - from ._models import ApplicationInsightsComponentAPIKey # type: ignore - from ._models import ApplicationInsightsComponentAPIKeyListResult # type: ignore - from ._models import ApplicationInsightsComponentAnalyticsItem # type: ignore - from ._models import ApplicationInsightsComponentAnalyticsItemProperties # type: ignore - from ._models import ApplicationInsightsComponentAvailableFeatures # type: ignore - from ._models import ApplicationInsightsComponentBillingFeatures # type: ignore - from ._models import ApplicationInsightsComponentDataVolumeCap # type: ignore - from ._models import ApplicationInsightsComponentExportConfiguration # type: ignore - from ._models import ApplicationInsightsComponentExportRequest # type: ignore - from ._models import ApplicationInsightsComponentFavorite # type: ignore - from ._models import ApplicationInsightsComponentFeature # type: ignore - from ._models import ApplicationInsightsComponentFeatureCapabilities # type: ignore - from ._models import ApplicationInsightsComponentFeatureCapability # type: ignore - from ._models import ApplicationInsightsComponentListResult # type: ignore - from ._models import ApplicationInsightsComponentProactiveDetectionConfiguration # type: ignore - from ._models import ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions # type: ignore - from ._models import ApplicationInsightsComponentQuotaStatus # type: ignore - from ._models import ApplicationInsightsComponentWebTestLocation # type: ignore - from ._models import ApplicationInsightsWebTestLocationsListResult # type: ignore - from ._models import ComponentPurgeBody # type: ignore - from ._models import ComponentPurgeBodyFilters # type: ignore - from ._models import ComponentPurgeResponse # type: ignore - from ._models import ComponentPurgeStatusResponse # type: ignore - from ._models import ComponentsResource # type: ignore - from ._models import ErrorFieldContract # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import InnerError # type: ignore - from ._models import LinkProperties # type: ignore - from ._models import MyWorkbook # type: ignore - from ._models import MyWorkbookError # type: ignore - from ._models import MyWorkbookResource # type: ignore - from ._models import MyWorkbooksListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateLinkScopedResource # type: ignore - from ._models import TagsResource # type: ignore - from ._models import WebTest # type: ignore - from ._models import WebTestGeolocation # type: ignore - from ._models import WebTestListResult # type: ignore - from ._models import WebTestPropertiesConfiguration # type: ignore - from ._models import WebtestsResource # type: ignore - from ._models import WorkItemConfiguration # type: ignore - from ._models import WorkItemConfigurationError # type: ignore - from ._models import WorkItemConfigurationsListResult # type: ignore - from ._models import WorkItemCreateConfiguration # type: ignore - from ._models import Workbook # type: ignore - from ._models import WorkbookError # type: ignore - from ._models import WorkbookResource # type: ignore - from ._models import WorkbooksListResult # type: ignore +from ._models_py3 import APIKeyRequest +from ._models_py3 import Annotation +from ._models_py3 import AnnotationError +from ._models_py3 import AnnotationsListResult +from ._models_py3 import ApplicationInsightsComponent +from ._models_py3 import ApplicationInsightsComponentAPIKey +from ._models_py3 import ApplicationInsightsComponentAPIKeyListResult +from ._models_py3 import ApplicationInsightsComponentAnalyticsItem +from ._models_py3 import ApplicationInsightsComponentAnalyticsItemProperties +from ._models_py3 import ApplicationInsightsComponentAvailableFeatures +from ._models_py3 import ApplicationInsightsComponentBillingFeatures +from ._models_py3 import ApplicationInsightsComponentDataVolumeCap +from ._models_py3 import ApplicationInsightsComponentExportConfiguration +from ._models_py3 import ApplicationInsightsComponentExportRequest +from ._models_py3 import ApplicationInsightsComponentFavorite +from ._models_py3 import ApplicationInsightsComponentFeature +from ._models_py3 import ApplicationInsightsComponentFeatureCapabilities +from ._models_py3 import ApplicationInsightsComponentFeatureCapability +from ._models_py3 import ApplicationInsightsComponentListResult +from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfiguration +from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions +from ._models_py3 import ApplicationInsightsComponentQuotaStatus +from ._models_py3 import ApplicationInsightsComponentWebTestLocation +from ._models_py3 import ApplicationInsightsWebTestLocationsListResult +from ._models_py3 import ComponentPurgeBody +from ._models_py3 import ComponentPurgeBodyFilters +from ._models_py3 import ComponentPurgeResponse +from ._models_py3 import ComponentPurgeStatusResponse +from ._models_py3 import ComponentsResource +from ._models_py3 import ErrorFieldContract +from ._models_py3 import ErrorResponse +from ._models_py3 import InnerError +from ._models_py3 import LinkProperties +from ._models_py3 import MyWorkbook +from ._models_py3 import MyWorkbookError +from ._models_py3 import MyWorkbookResource +from ._models_py3 import MyWorkbooksListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateLinkScopedResource +from ._models_py3 import TagsResource +from ._models_py3 import WebTest +from ._models_py3 import WebTestGeolocation +from ._models_py3 import WebTestListResult +from ._models_py3 import WebTestPropertiesConfiguration +from ._models_py3 import WebtestsResource +from ._models_py3 import WorkItemConfiguration +from ._models_py3 import WorkItemConfigurationError +from ._models_py3 import WorkItemConfigurationsListResult +from ._models_py3 import WorkItemCreateConfiguration +from ._models_py3 import Workbook +from ._models_py3 import WorkbookError +from ._models_py3 import WorkbookResource +from ._models_py3 import WorkbooksListResult + from ._application_insights_management_client_enums import ( ApplicationType, diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_application_insights_management_client_enums.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_application_insights_management_client_enums.py index 4d8e2c9094800..4093a64b664ef 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_application_insights_management_client_enums.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_application_insights_management_client_enums.py @@ -6,41 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ApplicationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApplicationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of application being monitored. """ WEB = "web" OTHER = "other" -class CategoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WORKBOOK = "workbook" TSG = "TSG" PERFORMANCE = "performance" RETENTION = "retention" -class FavoriteSourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FavoriteSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RETENTION = "retention" NOTEBOOK = "notebook" @@ -51,7 +36,7 @@ class FavoriteSourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): IMPACT = "impact" SEGMENTATION = "segmentation" -class FavoriteType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FavoriteType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum indicating if this favorite definition is owned by a specific user or is shared between all users with access to the Application Insights component. """ @@ -59,7 +44,7 @@ class FavoriteType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SHARED = "shared" USER = "user" -class FlowType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FlowType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. @@ -67,7 +52,7 @@ class FlowType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BLUEFIELD = "Bluefield" -class IngestionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IngestionMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the flow of the ingestion. """ @@ -75,7 +60,7 @@ class IngestionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPLICATION_INSIGHTS_WITH_DIAGNOSTIC_SETTINGS = "ApplicationInsightsWithDiagnosticSettings" LOG_ANALYTICS = "LogAnalytics" -class ItemScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ItemScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum indicating if this item definition is owned by a specific user or is shared between all users with access to the Application Insights component. """ @@ -83,21 +68,21 @@ class ItemScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SHARED = "shared" USER = "user" -class ItemScopePath(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ItemScopePath(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ANALYTICS_ITEMS = "analyticsItems" MYANALYTICS_ITEMS = "myanalyticsItems" -class ItemType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ItemType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum indicating the type of the Analytics item. """ + NONE = "none" QUERY = "query" - FUNCTION = "function" - FOLDER = "folder" RECENT = "recent" + FUNCTION = "function" -class ItemTypeParameter(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ItemTypeParameter(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NONE = "none" QUERY = "query" @@ -105,28 +90,28 @@ class ItemTypeParameter(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FOLDER = "folder" RECENT = "recent" -class PurgeState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PurgeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the operation represented by the requested Id. """ PENDING = "pending" COMPLETED = "completed" -class RequestSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RequestSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. """ REST = "rest" -class SharedTypeKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SharedTypeKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of workbook. Choices are user and shared. """ USER = "user" SHARED = "shared" -class WebTestKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WebTestKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of web test that this web test watches. Choices are ping and multistep. """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models.py deleted file mode 100644 index 351649c9980ca..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models.py +++ /dev/null @@ -1,2272 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Annotation(msrest.serialization.Model): - """Annotation associated with an application insights resource. - - :param annotation_name: Name of annotation. - :type annotation_name: str - :param category: Category of annotation, free form. - :type category: str - :param event_time: Time when event occurred. - :type event_time: ~datetime.datetime - :param id: Unique Id for annotation. - :type id: str - :param properties: Serialized JSON object for detailed properties. - :type properties: str - :param related_annotation: Related parent annotation if any. - :type related_annotation: str - """ - - _attribute_map = { - 'annotation_name': {'key': 'AnnotationName', 'type': 'str'}, - 'category': {'key': 'Category', 'type': 'str'}, - 'event_time': {'key': 'EventTime', 'type': 'iso-8601'}, - 'id': {'key': 'Id', 'type': 'str'}, - 'properties': {'key': 'Properties', 'type': 'str'}, - 'related_annotation': {'key': 'RelatedAnnotation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Annotation, self).__init__(**kwargs) - self.annotation_name = kwargs.get('annotation_name', None) - self.category = kwargs.get('category', None) - self.event_time = kwargs.get('event_time', None) - self.id = kwargs.get('id', None) - self.properties = kwargs.get('properties', None) - self.related_annotation = kwargs.get('related_annotation', "null") - - -class AnnotationError(msrest.serialization.Model): - """Error associated with trying to create annotation with Id that already exist. - - :param code: Error detail code and explanation. - :type code: str - :param message: Error message. - :type message: str - :param innererror: Inner error. - :type innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'innererror': {'key': 'innererror', 'type': 'InnerError'}, - } - - def __init__( - self, - **kwargs - ): - super(AnnotationError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.innererror = kwargs.get('innererror', None) - - -class AnnotationsListResult(msrest.serialization.Model): - """Annotations list result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of annotations. - :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Annotation] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Annotation]'}, - } - - def __init__( - self, - **kwargs - ): - super(AnnotationsListResult, self).__init__(**kwargs) - self.value = None - - -class APIKeyRequest(msrest.serialization.Model): - """An Application Insights component API Key creation request definition. - - :param name: The name of the API Key. - :type name: str - :param linked_read_properties: The read access rights of this API Key. - :type linked_read_properties: list[str] - :param linked_write_properties: The write access rights of this API Key. - :type linked_write_properties: list[str] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'linked_read_properties': {'key': 'linkedReadProperties', 'type': '[str]'}, - 'linked_write_properties': {'key': 'linkedWriteProperties', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(APIKeyRequest, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.linked_read_properties = kwargs.get('linked_read_properties', None) - self.linked_write_properties = kwargs.get('linked_write_properties', None) - - -class ComponentsResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentsResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ApplicationInsightsComponent(ComponentsResource): - """An Application Insights component definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. The kind of application that this component refers to, used to customize - UI. This value is a freeform string, values should typically be one of the following: web, ios, - other, store, java, phone. - :type kind: str - :ivar application_id: The unique ID of your application. This field mirrors the 'Name' field - and cannot be changed. - :vartype application_id: str - :ivar app_id: Application Insights Unique ID for your Application. - :vartype app_id: str - :param application_type: Type of application being monitored. Possible values include: "web", - "other". Default value: "web". - :type application_type: str or - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationType - :param flow_type: Used by the Application Insights system to determine what kind of flow this - component was created by. This is to be set to 'Bluefield' when creating/updating a component - via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". - :type flow_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.FlowType - :param request_source: Describes what tool created this Application Insights component. - Customers using this API should set this to the default 'rest'. Possible values include: - "rest". Default value: "rest". - :type request_source: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.RequestSource - :ivar instrumentation_key: Application Insights Instrumentation key. A read-only value that - applications can use to identify the destination for all telemetry sent to Azure Application - Insights. This value will be supplied upon construction of each new Application Insights - component. - :vartype instrumentation_key: str - :ivar creation_date: Creation Date for the Application Insights component, in ISO 8601 format. - :vartype creation_date: ~datetime.datetime - :ivar tenant_id: Azure Tenant Id. - :vartype tenant_id: str - :param hockey_app_id: The unique application ID created when a new application is added to - HockeyApp, used for communications with HockeyApp. - :type hockey_app_id: str - :ivar hockey_app_token: Token used to authenticate communications with between Application - Insights and HockeyApp. - :vartype hockey_app_token: str - :ivar provisioning_state: Current state of this component: whether or not is has been - provisioned within the resource group it is defined. Users cannot change this value but are - able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. - :vartype provisioning_state: str - :param sampling_percentage: Percentage of the data produced by the application being monitored - that is being sampled for Application Insights telemetry. - :type sampling_percentage: float - :ivar connection_string: Application Insights component connection string. - :vartype connection_string: str - :param retention_in_days: Retention period in days. - :type retention_in_days: int - :param disable_ip_masking: Disable IP masking. - :type disable_ip_masking: bool - :param immediate_purge_data_on30_days: Purge data immediately after 30 days. - :type immediate_purge_data_on30_days: bool - :ivar private_link_scoped_resources: List of linked private link scope resources. - :vartype private_link_scoped_resources: - list[~azure.mgmt.applicationinsights.v2015_05_01.models.PrivateLinkScopedResource] - :param ingestion_mode: Indicates the flow of the ingestion. Possible values include: - "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default - value: "ApplicationInsights". - :type ingestion_mode: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.IngestionMode - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'application_id': {'readonly': True}, - 'app_id': {'readonly': True}, - 'instrumentation_key': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'hockey_app_token': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'connection_string': {'readonly': True}, - 'private_link_scoped_resources': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'application_id': {'key': 'properties.ApplicationId', 'type': 'str'}, - 'app_id': {'key': 'properties.AppId', 'type': 'str'}, - 'application_type': {'key': 'properties.Application_Type', 'type': 'str'}, - 'flow_type': {'key': 'properties.Flow_Type', 'type': 'str'}, - 'request_source': {'key': 'properties.Request_Source', 'type': 'str'}, - 'instrumentation_key': {'key': 'properties.InstrumentationKey', 'type': 'str'}, - 'creation_date': {'key': 'properties.CreationDate', 'type': 'iso-8601'}, - 'tenant_id': {'key': 'properties.TenantId', 'type': 'str'}, - 'hockey_app_id': {'key': 'properties.HockeyAppId', 'type': 'str'}, - 'hockey_app_token': {'key': 'properties.HockeyAppToken', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sampling_percentage': {'key': 'properties.SamplingPercentage', 'type': 'float'}, - 'connection_string': {'key': 'properties.ConnectionString', 'type': 'str'}, - 'retention_in_days': {'key': 'properties.RetentionInDays', 'type': 'int'}, - 'disable_ip_masking': {'key': 'properties.DisableIpMasking', 'type': 'bool'}, - 'immediate_purge_data_on30_days': {'key': 'properties.ImmediatePurgeDataOn30Days', 'type': 'bool'}, - 'private_link_scoped_resources': {'key': 'properties.PrivateLinkScopedResources', 'type': '[PrivateLinkScopedResource]'}, - 'ingestion_mode': {'key': 'properties.IngestionMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponent, self).__init__(**kwargs) - self.kind = kwargs['kind'] - self.application_id = None - self.app_id = None - self.application_type = kwargs.get('application_type', "web") - self.flow_type = kwargs.get('flow_type', "Bluefield") - self.request_source = kwargs.get('request_source', "rest") - self.instrumentation_key = None - self.creation_date = None - self.tenant_id = None - self.hockey_app_id = kwargs.get('hockey_app_id', None) - self.hockey_app_token = None - self.provisioning_state = None - self.sampling_percentage = kwargs.get('sampling_percentage', None) - self.connection_string = None - self.retention_in_days = kwargs.get('retention_in_days', 90) - self.disable_ip_masking = kwargs.get('disable_ip_masking', None) - self.immediate_purge_data_on30_days = kwargs.get('immediate_purge_data_on30_days', None) - self.private_link_scoped_resources = None - self.ingestion_mode = kwargs.get('ingestion_mode', "ApplicationInsights") - - -class ApplicationInsightsComponentAnalyticsItem(msrest.serialization.Model): - """Properties that define an Analytics item that is associated to an Application Insights component. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Internally assigned unique id of the item definition. - :type id: str - :param name: The user-defined name of the item. - :type name: str - :param content: The content of this item. - :type content: str - :ivar version: This instance's version of the data model. This can change as new features are - added. - :vartype version: str - :param scope: Enum indicating if this item definition is owned by a specific user or is shared - between all users with access to the Application Insights component. Possible values include: - "shared", "user". - :type scope: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScope - :param type: Enum indicating the type of the Analytics item. Possible values include: "query", - "function", "folder", "recent". - :type type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemType - :ivar time_created: Date and time in UTC when this item was created. - :vartype time_created: str - :ivar time_modified: Date and time in UTC of the last modification that was made to this item. - :vartype time_modified: str - :param properties: A set of properties that can be defined in the context of a specific item - type. Each type may have its own properties. - :type properties: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItemProperties - """ - - _validation = { - 'version': {'readonly': True}, - 'time_created': {'readonly': True}, - 'time_modified': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'Id', 'type': 'str'}, - 'name': {'key': 'Name', 'type': 'str'}, - 'content': {'key': 'Content', 'type': 'str'}, - 'version': {'key': 'Version', 'type': 'str'}, - 'scope': {'key': 'Scope', 'type': 'str'}, - 'type': {'key': 'Type', 'type': 'str'}, - 'time_created': {'key': 'TimeCreated', 'type': 'str'}, - 'time_modified': {'key': 'TimeModified', 'type': 'str'}, - 'properties': {'key': 'Properties', 'type': 'ApplicationInsightsComponentAnalyticsItemProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentAnalyticsItem, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.content = kwargs.get('content', None) - self.version = None - self.scope = kwargs.get('scope', None) - self.type = kwargs.get('type', None) - self.time_created = None - self.time_modified = None - self.properties = kwargs.get('properties', None) - - -class ApplicationInsightsComponentAnalyticsItemProperties(msrest.serialization.Model): - """A set of properties that can be defined in the context of a specific item type. Each type may have its own properties. - - :param function_alias: A function alias, used when the type of the item is Function. - :type function_alias: str - """ - - _attribute_map = { - 'function_alias': {'key': 'functionAlias', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentAnalyticsItemProperties, self).__init__(**kwargs) - self.function_alias = kwargs.get('function_alias', None) - - -class ApplicationInsightsComponentAPIKey(msrest.serialization.Model): - """Properties that define an API key of an Application Insights Component. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The unique ID of the API key inside an Application Insights component. It is auto - generated when the API key is created. - :vartype id: str - :ivar api_key: The API key value. It will be only return once when the API Key was created. - :vartype api_key: str - :param created_date: The create date of this API key. - :type created_date: str - :param name: The name of the API key. - :type name: str - :param linked_read_properties: The read access rights of this API Key. - :type linked_read_properties: list[str] - :param linked_write_properties: The write access rights of this API Key. - :type linked_write_properties: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'api_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'api_key': {'key': 'apiKey', 'type': 'str'}, - 'created_date': {'key': 'createdDate', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'linked_read_properties': {'key': 'linkedReadProperties', 'type': '[str]'}, - 'linked_write_properties': {'key': 'linkedWriteProperties', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentAPIKey, self).__init__(**kwargs) - self.id = None - self.api_key = None - self.created_date = kwargs.get('created_date', None) - self.name = kwargs.get('name', None) - self.linked_read_properties = kwargs.get('linked_read_properties', None) - self.linked_write_properties = kwargs.get('linked_write_properties', None) - - -class ApplicationInsightsComponentAPIKeyListResult(msrest.serialization.Model): - """Describes the list of API Keys of an Application Insights Component. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of API Key definitions. - :type value: - list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationInsightsComponentAPIKey]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentAPIKeyListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class ApplicationInsightsComponentAvailableFeatures(msrest.serialization.Model): - """An Application Insights component available features. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar result: A list of Application Insights component feature. - :vartype result: - list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeature] - """ - - _validation = { - 'result': {'readonly': True}, - } - - _attribute_map = { - 'result': {'key': 'Result', 'type': '[ApplicationInsightsComponentFeature]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentAvailableFeatures, self).__init__(**kwargs) - self.result = None - - -class ApplicationInsightsComponentBillingFeatures(msrest.serialization.Model): - """An Application Insights component billing features. - - :param data_volume_cap: An Application Insights component daily data volume cap. - :type data_volume_cap: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentDataVolumeCap - :param current_billing_features: Current enabled pricing plan. When the component is in the - Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'. - :type current_billing_features: list[str] - """ - - _attribute_map = { - 'data_volume_cap': {'key': 'DataVolumeCap', 'type': 'ApplicationInsightsComponentDataVolumeCap'}, - 'current_billing_features': {'key': 'CurrentBillingFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentBillingFeatures, self).__init__(**kwargs) - self.data_volume_cap = kwargs.get('data_volume_cap', None) - self.current_billing_features = kwargs.get('current_billing_features', None) - - -class ApplicationInsightsComponentDataVolumeCap(msrest.serialization.Model): - """An Application Insights component daily data volume cap. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param cap: Daily data volume cap in GB. - :type cap: float - :ivar reset_time: Daily data volume cap UTC reset hour. - :vartype reset_time: int - :param warning_threshold: Reserved, not used for now. - :type warning_threshold: int - :param stop_send_notification_when_hit_threshold: Reserved, not used for now. - :type stop_send_notification_when_hit_threshold: bool - :param stop_send_notification_when_hit_cap: Do not send a notification email when the daily - data volume cap is met. - :type stop_send_notification_when_hit_cap: bool - :ivar max_history_cap: Maximum daily data volume cap that the user can set for this component. - :vartype max_history_cap: float - """ - - _validation = { - 'reset_time': {'readonly': True}, - 'max_history_cap': {'readonly': True}, - } - - _attribute_map = { - 'cap': {'key': 'Cap', 'type': 'float'}, - 'reset_time': {'key': 'ResetTime', 'type': 'int'}, - 'warning_threshold': {'key': 'WarningThreshold', 'type': 'int'}, - 'stop_send_notification_when_hit_threshold': {'key': 'StopSendNotificationWhenHitThreshold', 'type': 'bool'}, - 'stop_send_notification_when_hit_cap': {'key': 'StopSendNotificationWhenHitCap', 'type': 'bool'}, - 'max_history_cap': {'key': 'MaxHistoryCap', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentDataVolumeCap, self).__init__(**kwargs) - self.cap = kwargs.get('cap', None) - self.reset_time = None - self.warning_threshold = kwargs.get('warning_threshold', None) - self.stop_send_notification_when_hit_threshold = kwargs.get('stop_send_notification_when_hit_threshold', None) - self.stop_send_notification_when_hit_cap = kwargs.get('stop_send_notification_when_hit_cap', None) - self.max_history_cap = None - - -class ApplicationInsightsComponentExportConfiguration(msrest.serialization.Model): - """Properties that define a Continuous Export configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar export_id: The unique ID of the export configuration inside an Application Insights - component. It is auto generated when the Continuous Export configuration is created. - :vartype export_id: str - :ivar instrumentation_key: The instrumentation key of the Application Insights component. - :vartype instrumentation_key: str - :param record_types: This comma separated list of document types that will be exported. The - possible values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', - 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. - :type record_types: str - :ivar application_name: The name of the Application Insights component. - :vartype application_name: str - :ivar subscription_id: The subscription of the Application Insights component. - :vartype subscription_id: str - :ivar resource_group: The resource group of the Application Insights component. - :vartype resource_group: str - :ivar destination_storage_subscription_id: The destination storage account subscription ID. - :vartype destination_storage_subscription_id: str - :ivar destination_storage_location_id: The destination account location ID. - :vartype destination_storage_location_id: str - :ivar destination_account_id: The name of destination account. - :vartype destination_account_id: str - :ivar destination_type: The destination type. - :vartype destination_type: str - :ivar is_user_enabled: This will be 'true' if the Continuous Export configuration is enabled, - otherwise it will be 'false'. - :vartype is_user_enabled: str - :ivar last_user_update: Last time the Continuous Export configuration was updated. - :vartype last_user_update: str - :param notification_queue_enabled: Deprecated. - :type notification_queue_enabled: str - :ivar export_status: This indicates current Continuous Export configuration status. The - possible values are 'Preparing', 'Success', 'Failure'. - :vartype export_status: str - :ivar last_success_time: The last time data was successfully delivered to the destination - storage container for this Continuous Export configuration. - :vartype last_success_time: str - :ivar last_gap_time: The last time the Continuous Export configuration started failing. - :vartype last_gap_time: str - :ivar permanent_error_reason: This is the reason the Continuous Export configuration started - failing. It can be 'AzureStorageNotFound' or 'AzureStorageAccessDenied'. - :vartype permanent_error_reason: str - :ivar storage_name: The name of the destination storage account. - :vartype storage_name: str - :ivar container_name: The name of the destination storage container. - :vartype container_name: str - """ - - _validation = { - 'export_id': {'readonly': True}, - 'instrumentation_key': {'readonly': True}, - 'application_name': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'resource_group': {'readonly': True}, - 'destination_storage_subscription_id': {'readonly': True}, - 'destination_storage_location_id': {'readonly': True}, - 'destination_account_id': {'readonly': True}, - 'destination_type': {'readonly': True}, - 'is_user_enabled': {'readonly': True}, - 'last_user_update': {'readonly': True}, - 'export_status': {'readonly': True}, - 'last_success_time': {'readonly': True}, - 'last_gap_time': {'readonly': True}, - 'permanent_error_reason': {'readonly': True}, - 'storage_name': {'readonly': True}, - 'container_name': {'readonly': True}, - } - - _attribute_map = { - 'export_id': {'key': 'ExportId', 'type': 'str'}, - 'instrumentation_key': {'key': 'InstrumentationKey', 'type': 'str'}, - 'record_types': {'key': 'RecordTypes', 'type': 'str'}, - 'application_name': {'key': 'ApplicationName', 'type': 'str'}, - 'subscription_id': {'key': 'SubscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'ResourceGroup', 'type': 'str'}, - 'destination_storage_subscription_id': {'key': 'DestinationStorageSubscriptionId', 'type': 'str'}, - 'destination_storage_location_id': {'key': 'DestinationStorageLocationId', 'type': 'str'}, - 'destination_account_id': {'key': 'DestinationAccountId', 'type': 'str'}, - 'destination_type': {'key': 'DestinationType', 'type': 'str'}, - 'is_user_enabled': {'key': 'IsUserEnabled', 'type': 'str'}, - 'last_user_update': {'key': 'LastUserUpdate', 'type': 'str'}, - 'notification_queue_enabled': {'key': 'NotificationQueueEnabled', 'type': 'str'}, - 'export_status': {'key': 'ExportStatus', 'type': 'str'}, - 'last_success_time': {'key': 'LastSuccessTime', 'type': 'str'}, - 'last_gap_time': {'key': 'LastGapTime', 'type': 'str'}, - 'permanent_error_reason': {'key': 'PermanentErrorReason', 'type': 'str'}, - 'storage_name': {'key': 'StorageName', 'type': 'str'}, - 'container_name': {'key': 'ContainerName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentExportConfiguration, self).__init__(**kwargs) - self.export_id = None - self.instrumentation_key = None - self.record_types = kwargs.get('record_types', None) - self.application_name = None - self.subscription_id = None - self.resource_group = None - self.destination_storage_subscription_id = None - self.destination_storage_location_id = None - self.destination_account_id = None - self.destination_type = None - self.is_user_enabled = None - self.last_user_update = None - self.notification_queue_enabled = kwargs.get('notification_queue_enabled', None) - self.export_status = None - self.last_success_time = None - self.last_gap_time = None - self.permanent_error_reason = None - self.storage_name = None - self.container_name = None - - -class ApplicationInsightsComponentExportRequest(msrest.serialization.Model): - """An Application Insights component Continuous Export configuration request definition. - - :param record_types: The document types to be exported, as comma separated values. Allowed - values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', - 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. - :type record_types: str - :param destination_type: The Continuous Export destination type. This has to be 'Blob'. - :type destination_type: str - :param destination_address: The SAS URL for the destination storage container. It must grant - write permission. - :type destination_address: str - :param is_enabled: Set to 'true' to create a Continuous Export configuration as enabled, - otherwise set it to 'false'. - :type is_enabled: str - :param notification_queue_enabled: Deprecated. - :type notification_queue_enabled: str - :param notification_queue_uri: Deprecated. - :type notification_queue_uri: str - :param destination_storage_subscription_id: The subscription ID of the destination storage - container. - :type destination_storage_subscription_id: str - :param destination_storage_location_id: The location ID of the destination storage container. - :type destination_storage_location_id: str - :param destination_account_id: The name of destination storage account. - :type destination_account_id: str - """ - - _attribute_map = { - 'record_types': {'key': 'RecordTypes', 'type': 'str'}, - 'destination_type': {'key': 'DestinationType', 'type': 'str'}, - 'destination_address': {'key': 'DestinationAddress', 'type': 'str'}, - 'is_enabled': {'key': 'IsEnabled', 'type': 'str'}, - 'notification_queue_enabled': {'key': 'NotificationQueueEnabled', 'type': 'str'}, - 'notification_queue_uri': {'key': 'NotificationQueueUri', 'type': 'str'}, - 'destination_storage_subscription_id': {'key': 'DestinationStorageSubscriptionId', 'type': 'str'}, - 'destination_storage_location_id': {'key': 'DestinationStorageLocationId', 'type': 'str'}, - 'destination_account_id': {'key': 'DestinationAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentExportRequest, self).__init__(**kwargs) - self.record_types = kwargs.get('record_types', None) - self.destination_type = kwargs.get('destination_type', None) - self.destination_address = kwargs.get('destination_address', None) - self.is_enabled = kwargs.get('is_enabled', None) - self.notification_queue_enabled = kwargs.get('notification_queue_enabled', None) - self.notification_queue_uri = kwargs.get('notification_queue_uri', None) - self.destination_storage_subscription_id = kwargs.get('destination_storage_subscription_id', None) - self.destination_storage_location_id = kwargs.get('destination_storage_location_id', None) - self.destination_account_id = kwargs.get('destination_account_id', None) - - -class ApplicationInsightsComponentFavorite(msrest.serialization.Model): - """Properties that define a favorite that is associated to an Application Insights component. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: The user-defined name of the favorite. - :type name: str - :param config: Configuration of this particular favorite, which are driven by the Azure portal - UX. Configuration data is a string containing valid JSON. - :type config: str - :param version: This instance's version of the data model. This can change as new features are - added that can be marked favorite. Current examples include MetricsExplorer (ME) and Search. - :type version: str - :ivar favorite_id: Internally assigned unique id of the favorite definition. - :vartype favorite_id: str - :param favorite_type: Enum indicating if this favorite definition is owned by a specific user - or is shared between all users with access to the Application Insights component. Possible - values include: "shared", "user". - :type favorite_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.FavoriteType - :param source_type: The source of the favorite definition. - :type source_type: str - :ivar time_modified: Date and time in UTC of the last modification that was made to this - favorite definition. - :vartype time_modified: str - :param tags: A set of tags. A list of 0 or more tags that are associated with this favorite - definition. - :type tags: list[str] - :param category: Favorite category, as defined by the user at creation time. - :type category: str - :param is_generated_from_template: Flag denoting wether or not this favorite was generated from - a template. - :type is_generated_from_template: bool - :ivar user_id: Unique user id of the specific user that owns this favorite. - :vartype user_id: str - """ - - _validation = { - 'favorite_id': {'readonly': True}, - 'time_modified': {'readonly': True}, - 'user_id': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'config': {'key': 'Config', 'type': 'str'}, - 'version': {'key': 'Version', 'type': 'str'}, - 'favorite_id': {'key': 'FavoriteId', 'type': 'str'}, - 'favorite_type': {'key': 'FavoriteType', 'type': 'str'}, - 'source_type': {'key': 'SourceType', 'type': 'str'}, - 'time_modified': {'key': 'TimeModified', 'type': 'str'}, - 'tags': {'key': 'Tags', 'type': '[str]'}, - 'category': {'key': 'Category', 'type': 'str'}, - 'is_generated_from_template': {'key': 'IsGeneratedFromTemplate', 'type': 'bool'}, - 'user_id': {'key': 'UserId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentFavorite, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.config = kwargs.get('config', None) - self.version = kwargs.get('version', None) - self.favorite_id = None - self.favorite_type = kwargs.get('favorite_type', None) - self.source_type = kwargs.get('source_type', None) - self.time_modified = None - self.tags = kwargs.get('tags', None) - self.category = kwargs.get('category', None) - self.is_generated_from_template = kwargs.get('is_generated_from_template', None) - self.user_id = None - - -class ApplicationInsightsComponentFeature(msrest.serialization.Model): - """An Application Insights component daily data volume cap status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar feature_name: The pricing feature name. - :vartype feature_name: str - :ivar meter_id: The meter id used for the feature. - :vartype meter_id: str - :ivar meter_rate_frequency: The meter rate for the feature's meter. - :vartype meter_rate_frequency: str - :ivar resouce_id: Reserved, not used now. - :vartype resouce_id: str - :ivar is_hidden: Reserved, not used now. - :vartype is_hidden: bool - :ivar capabilities: A list of Application Insights component feature capability. - :vartype capabilities: - list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeatureCapability] - :ivar title: Display name of the feature. - :vartype title: str - :ivar is_main_feature: Whether can apply addon feature on to it. - :vartype is_main_feature: bool - :ivar supported_addon_features: The add on features on main feature. - :vartype supported_addon_features: str - """ - - _validation = { - 'feature_name': {'readonly': True}, - 'meter_id': {'readonly': True}, - 'meter_rate_frequency': {'readonly': True}, - 'resouce_id': {'readonly': True}, - 'is_hidden': {'readonly': True}, - 'capabilities': {'readonly': True}, - 'title': {'readonly': True}, - 'is_main_feature': {'readonly': True}, - 'supported_addon_features': {'readonly': True}, - } - - _attribute_map = { - 'feature_name': {'key': 'FeatureName', 'type': 'str'}, - 'meter_id': {'key': 'MeterId', 'type': 'str'}, - 'meter_rate_frequency': {'key': 'MeterRateFrequency', 'type': 'str'}, - 'resouce_id': {'key': 'ResouceId', 'type': 'str'}, - 'is_hidden': {'key': 'IsHidden', 'type': 'bool'}, - 'capabilities': {'key': 'Capabilities', 'type': '[ApplicationInsightsComponentFeatureCapability]'}, - 'title': {'key': 'Title', 'type': 'str'}, - 'is_main_feature': {'key': 'IsMainFeature', 'type': 'bool'}, - 'supported_addon_features': {'key': 'SupportedAddonFeatures', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentFeature, self).__init__(**kwargs) - self.feature_name = None - self.meter_id = None - self.meter_rate_frequency = None - self.resouce_id = None - self.is_hidden = None - self.capabilities = None - self.title = None - self.is_main_feature = None - self.supported_addon_features = None - - -class ApplicationInsightsComponentFeatureCapabilities(msrest.serialization.Model): - """An Application Insights component feature capabilities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar support_export_data: Whether allow to use continuous export feature. - :vartype support_export_data: bool - :ivar burst_throttle_policy: Reserved, not used now. - :vartype burst_throttle_policy: str - :ivar metadata_class: Reserved, not used now. - :vartype metadata_class: str - :ivar live_stream_metrics: Reserved, not used now. - :vartype live_stream_metrics: bool - :ivar application_map: Reserved, not used now. - :vartype application_map: bool - :ivar work_item_integration: Whether allow to use work item integration feature. - :vartype work_item_integration: bool - :ivar power_bi_integration: Reserved, not used now. - :vartype power_bi_integration: bool - :ivar open_schema: Reserved, not used now. - :vartype open_schema: bool - :ivar proactive_detection: Reserved, not used now. - :vartype proactive_detection: bool - :ivar analytics_integration: Reserved, not used now. - :vartype analytics_integration: bool - :ivar multiple_step_web_test: Whether allow to use multiple steps web test feature. - :vartype multiple_step_web_test: bool - :ivar api_access_level: Reserved, not used now. - :vartype api_access_level: str - :ivar tracking_type: The application insights component used tracking type. - :vartype tracking_type: str - :ivar daily_cap: Daily data volume cap in GB. - :vartype daily_cap: float - :ivar daily_cap_reset_time: Daily data volume cap UTC reset hour. - :vartype daily_cap_reset_time: float - :ivar throttle_rate: Reserved, not used now. - :vartype throttle_rate: float - """ - - _validation = { - 'support_export_data': {'readonly': True}, - 'burst_throttle_policy': {'readonly': True}, - 'metadata_class': {'readonly': True}, - 'live_stream_metrics': {'readonly': True}, - 'application_map': {'readonly': True}, - 'work_item_integration': {'readonly': True}, - 'power_bi_integration': {'readonly': True}, - 'open_schema': {'readonly': True}, - 'proactive_detection': {'readonly': True}, - 'analytics_integration': {'readonly': True}, - 'multiple_step_web_test': {'readonly': True}, - 'api_access_level': {'readonly': True}, - 'tracking_type': {'readonly': True}, - 'daily_cap': {'readonly': True}, - 'daily_cap_reset_time': {'readonly': True}, - 'throttle_rate': {'readonly': True}, - } - - _attribute_map = { - 'support_export_data': {'key': 'SupportExportData', 'type': 'bool'}, - 'burst_throttle_policy': {'key': 'BurstThrottlePolicy', 'type': 'str'}, - 'metadata_class': {'key': 'MetadataClass', 'type': 'str'}, - 'live_stream_metrics': {'key': 'LiveStreamMetrics', 'type': 'bool'}, - 'application_map': {'key': 'ApplicationMap', 'type': 'bool'}, - 'work_item_integration': {'key': 'WorkItemIntegration', 'type': 'bool'}, - 'power_bi_integration': {'key': 'PowerBIIntegration', 'type': 'bool'}, - 'open_schema': {'key': 'OpenSchema', 'type': 'bool'}, - 'proactive_detection': {'key': 'ProactiveDetection', 'type': 'bool'}, - 'analytics_integration': {'key': 'AnalyticsIntegration', 'type': 'bool'}, - 'multiple_step_web_test': {'key': 'MultipleStepWebTest', 'type': 'bool'}, - 'api_access_level': {'key': 'ApiAccessLevel', 'type': 'str'}, - 'tracking_type': {'key': 'TrackingType', 'type': 'str'}, - 'daily_cap': {'key': 'DailyCap', 'type': 'float'}, - 'daily_cap_reset_time': {'key': 'DailyCapResetTime', 'type': 'float'}, - 'throttle_rate': {'key': 'ThrottleRate', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentFeatureCapabilities, self).__init__(**kwargs) - self.support_export_data = None - self.burst_throttle_policy = None - self.metadata_class = None - self.live_stream_metrics = None - self.application_map = None - self.work_item_integration = None - self.power_bi_integration = None - self.open_schema = None - self.proactive_detection = None - self.analytics_integration = None - self.multiple_step_web_test = None - self.api_access_level = None - self.tracking_type = None - self.daily_cap = None - self.daily_cap_reset_time = None - self.throttle_rate = None - - -class ApplicationInsightsComponentFeatureCapability(msrest.serialization.Model): - """An Application Insights component feature capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the capability. - :vartype name: str - :ivar description: The description of the capability. - :vartype description: str - :ivar value: The value of the capability. - :vartype value: str - :ivar unit: The unit of the capability. - :vartype unit: str - :ivar meter_id: The meter used for the capability. - :vartype meter_id: str - :ivar meter_rate_frequency: The meter rate of the meter. - :vartype meter_rate_frequency: str - """ - - _validation = { - 'name': {'readonly': True}, - 'description': {'readonly': True}, - 'value': {'readonly': True}, - 'unit': {'readonly': True}, - 'meter_id': {'readonly': True}, - 'meter_rate_frequency': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'description': {'key': 'Description', 'type': 'str'}, - 'value': {'key': 'Value', 'type': 'str'}, - 'unit': {'key': 'Unit', 'type': 'str'}, - 'meter_id': {'key': 'MeterId', 'type': 'str'}, - 'meter_rate_frequency': {'key': 'MeterRateFrequency', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentFeatureCapability, self).__init__(**kwargs) - self.name = None - self.description = None - self.value = None - self.unit = None - self.meter_id = None - self.meter_rate_frequency = None - - -class ApplicationInsightsComponentListResult(msrest.serialization.Model): - """Describes the list of Application Insights Resources. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of Application Insights component definitions. - :type value: - list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent] - :param next_link: The URI to get the next set of Application Insights component definitions if - too many components where returned in the result set. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationInsightsComponent]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class ApplicationInsightsComponentProactiveDetectionConfiguration(msrest.serialization.Model): - """Properties that define a ProactiveDetection configuration. - - :param name: The rule name. - :type name: str - :param enabled: A flag that indicates whether this rule is enabled by the user. - :type enabled: bool - :param send_emails_to_subscription_owners: A flag that indicated whether notifications on this - rule should be sent to subscription owners. - :type send_emails_to_subscription_owners: bool - :param custom_emails: Custom email addresses for this rule notifications. - :type custom_emails: list[str] - :param last_updated_time: The last time this rule was updated. - :type last_updated_time: str - :param rule_definitions: Static definitions of the ProactiveDetection configuration rule (same - values for all components). - :type rule_definitions: - ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions - """ - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'enabled': {'key': 'Enabled', 'type': 'bool'}, - 'send_emails_to_subscription_owners': {'key': 'SendEmailsToSubscriptionOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'CustomEmails', 'type': '[str]'}, - 'last_updated_time': {'key': 'LastUpdatedTime', 'type': 'str'}, - 'rule_definitions': {'key': 'RuleDefinitions', 'type': 'ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentProactiveDetectionConfiguration, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.enabled = kwargs.get('enabled', None) - self.send_emails_to_subscription_owners = kwargs.get('send_emails_to_subscription_owners', None) - self.custom_emails = kwargs.get('custom_emails', None) - self.last_updated_time = kwargs.get('last_updated_time', None) - self.rule_definitions = kwargs.get('rule_definitions', None) - - -class ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions(msrest.serialization.Model): - """Static definitions of the ProactiveDetection configuration rule (same values for all components). - - :param name: The rule name. - :type name: str - :param display_name: The rule name as it is displayed in UI. - :type display_name: str - :param description: The rule description. - :type description: str - :param help_url: URL which displays additional info about the proactive detection rule. - :type help_url: str - :param is_hidden: A flag indicating whether the rule is hidden (from the UI). - :type is_hidden: bool - :param is_enabled_by_default: A flag indicating whether the rule is enabled by default. - :type is_enabled_by_default: bool - :param is_in_preview: A flag indicating whether the rule is in preview. - :type is_in_preview: bool - :param supports_email_notifications: A flag indicating whether email notifications are - supported for detections for this rule. - :type supports_email_notifications: bool - """ - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'display_name': {'key': 'DisplayName', 'type': 'str'}, - 'description': {'key': 'Description', 'type': 'str'}, - 'help_url': {'key': 'HelpUrl', 'type': 'str'}, - 'is_hidden': {'key': 'IsHidden', 'type': 'bool'}, - 'is_enabled_by_default': {'key': 'IsEnabledByDefault', 'type': 'bool'}, - 'is_in_preview': {'key': 'IsInPreview', 'type': 'bool'}, - 'supports_email_notifications': {'key': 'SupportsEmailNotifications', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.help_url = kwargs.get('help_url', None) - self.is_hidden = kwargs.get('is_hidden', None) - self.is_enabled_by_default = kwargs.get('is_enabled_by_default', None) - self.is_in_preview = kwargs.get('is_in_preview', None) - self.supports_email_notifications = kwargs.get('supports_email_notifications', None) - - -class ApplicationInsightsComponentQuotaStatus(msrest.serialization.Model): - """An Application Insights component daily data volume cap status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar app_id: The Application ID for the Application Insights component. - :vartype app_id: str - :ivar should_be_throttled: The daily data volume cap is met, and data ingestion will be - stopped. - :vartype should_be_throttled: bool - :ivar expiration_time: Date and time when the daily data volume cap will be reset, and data - ingestion will resume. - :vartype expiration_time: str - """ - - _validation = { - 'app_id': {'readonly': True}, - 'should_be_throttled': {'readonly': True}, - 'expiration_time': {'readonly': True}, - } - - _attribute_map = { - 'app_id': {'key': 'AppId', 'type': 'str'}, - 'should_be_throttled': {'key': 'ShouldBeThrottled', 'type': 'bool'}, - 'expiration_time': {'key': 'ExpirationTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentQuotaStatus, self).__init__(**kwargs) - self.app_id = None - self.should_be_throttled = None - self.expiration_time = None - - -class ApplicationInsightsComponentWebTestLocation(msrest.serialization.Model): - """Properties that define a web test location available to an Application Insights Component. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar display_name: The display name of the web test location. - :vartype display_name: str - :ivar tag: Internally defined geographic location tag. - :vartype tag: str - """ - - _validation = { - 'display_name': {'readonly': True}, - 'tag': {'readonly': True}, - } - - _attribute_map = { - 'display_name': {'key': 'DisplayName', 'type': 'str'}, - 'tag': {'key': 'Tag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentWebTestLocation, self).__init__(**kwargs) - self.display_name = None - self.tag = None - - -class ApplicationInsightsWebTestLocationsListResult(msrest.serialization.Model): - """Describes the list of web test locations available to an Application Insights Component. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of web test locations. - :type value: - list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentWebTestLocation] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationInsightsComponentWebTestLocation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsWebTestLocationsListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class ComponentPurgeBody(msrest.serialization.Model): - """Describes the body of a purge request for an App Insights component. - - All required parameters must be populated in order to send to Azure. - - :param table: Required. Table from which to purge data. - :type table: str - :param filters: Required. The set of columns and filters (queries) to run over them to purge - the resulting data. - :type filters: - list[~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeBodyFilters] - """ - - _validation = { - 'table': {'required': True}, - 'filters': {'required': True}, - } - - _attribute_map = { - 'table': {'key': 'table', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': '[ComponentPurgeBodyFilters]'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeBody, self).__init__(**kwargs) - self.table = kwargs['table'] - self.filters = kwargs['filters'] - - -class ComponentPurgeBodyFilters(msrest.serialization.Model): - """User-defined filters to return data which will be purged from the table. - - :param column: The column of the table over which the given query should run. - :type column: str - :param operator: A query operator to evaluate over the provided column and value(s). Supported - operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would - in a KQL query. - :type operator: str - :param value: the value for the operator to function over. This can be a number (e.g., > 100), - a string (timestamp >= '2017-09-01') or array of values. - :type value: any - :param key: When filtering over custom dimensions, this key will be used as the name of the - custom dimension. - :type key: str - """ - - _attribute_map = { - 'column': {'key': 'column', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'object'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeBodyFilters, self).__init__(**kwargs) - self.column = kwargs.get('column', None) - self.operator = kwargs.get('operator', None) - self.value = kwargs.get('value', None) - self.key = kwargs.get('key', None) - - -class ComponentPurgeResponse(msrest.serialization.Model): - """Response containing operationId for a specific purge action. - - All required parameters must be populated in order to send to Azure. - - :param operation_id: Required. Id to use when querying for status for a particular purge - operation. - :type operation_id: str - """ - - _validation = { - 'operation_id': {'required': True}, - } - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeResponse, self).__init__(**kwargs) - self.operation_id = kwargs['operation_id'] - - -class ComponentPurgeStatusResponse(msrest.serialization.Model): - """Response containing status for a specific purge operation. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the operation represented by the requested Id. Possible - values include: "pending", "completed". - :type status: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.PurgeState - """ - - _validation = { - 'status': {'required': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeStatusResponse, self).__init__(**kwargs) - self.status = kwargs['status'] - - -class ErrorFieldContract(msrest.serialization.Model): - """Error Field contract. - - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorFieldContract, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class InnerError(msrest.serialization.Model): - """Inner error. - - :param diagnosticcontext: Provides correlation for request. - :type diagnosticcontext: str - :param time: Request time. - :type time: ~datetime.datetime - """ - - _attribute_map = { - 'diagnosticcontext': {'key': 'diagnosticcontext', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(InnerError, self).__init__(**kwargs) - self.diagnosticcontext = kwargs.get('diagnosticcontext', None) - self.time = kwargs.get('time', None) - - -class LinkProperties(msrest.serialization.Model): - """Contains a sourceId and workbook resource id to link two resources. - - :param source_id: The source Azure resource id. - :type source_id: str - :param target_id: The workbook Azure resource id. - :type target_id: str - :param category: The category of workbook. - :type category: str - """ - - _attribute_map = { - 'source_id': {'key': 'sourceId', 'type': 'str'}, - 'target_id': {'key': 'targetId', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LinkProperties, self).__init__(**kwargs) - self.source_id = kwargs.get('source_id', None) - self.target_id = kwargs.get('target_id', None) - self.category = kwargs.get('category', None) - - -class MyWorkbookResource(msrest.serialization.Model): - """An azure resource object. - - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbookResource, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class MyWorkbook(MyWorkbookResource): - """An Application Insights private workbook definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind - :param display_name: The user-defined name of the private workbook. - :type display_name: str - :param serialized_data: Configuration of this particular private workbook. Configuration data - is a string containing valid JSON. - :type serialized_data: str - :param version: This instance's version of the data model. This can change as new features are - added that can be marked private workbook. - :type version: str - :ivar time_modified: Date and time in UTC of the last modification that was made to this - private workbook definition. - :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this private - workbook definition. - :type tags_properties_tags: list[str] - :ivar user_id: Unique user id of the specific user that owns this private workbook. - :vartype user_id: str - :param source_id: Optional resourceId for a source resource. - :type source_id: str - """ - - _validation = { - 'time_modified': {'readonly': True}, - 'user_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'time_modified': {'key': 'properties.timeModified', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'tags_properties_tags': {'key': 'properties.tags', 'type': '[str]'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - 'source_id': {'key': 'properties.sourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbook, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.display_name = kwargs.get('display_name', None) - self.serialized_data = kwargs.get('serialized_data', None) - self.version = kwargs.get('version', None) - self.time_modified = None - self.category = kwargs.get('category', None) - self.tags_properties_tags = kwargs.get('tags_properties_tags', None) - self.user_id = None - self.source_id = kwargs.get('source_id', None) - - -class MyWorkbookError(msrest.serialization.Model): - """Error message body that will indicate why the operation failed. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbookError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class MyWorkbooksListResult(msrest.serialization.Model): - """Workbook list result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of private workbooks. - :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbook] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MyWorkbook]'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbooksListResult, self).__init__(**kwargs) - self.value = None - - -class Operation(msrest.serialization.Model): - """CDN REST API operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.applicationinsights.v2015_05_01.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.Cdn. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - - -class OperationListResult(msrest.serialization.Model): - """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. - - :param value: List of CDN operations supported by the CDN resource provider. - :type value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PrivateLinkScopedResource(msrest.serialization.Model): - """The private link scope resource reference. - - :param resource_id: The full resource Id of the private link scope resource. - :type resource_id: str - :param scope_id: The private link scope unique Identifier. - :type scope_id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'ResourceId', 'type': 'str'}, - 'scope_id': {'key': 'ScopeId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkScopedResource, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.scope_id = kwargs.get('scope_id', None) - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on a WebTest instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class WebtestsResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(WebtestsResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class WebTest(WebtestsResource): - """An Application Insights web test definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of web test that this web test watches. Choices are ping and multistep. - Possible values include: "ping", "multistep". - :type kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind - :param synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as the - Name field. - :type synthetic_monitor_id: str - :param web_test_name: User defined name if this WebTest. - :type web_test_name: str - :param description: Purpose/user defined descriptive test for this WebTest. - :type description: str - :param enabled: Is the test actively being monitored. - :type enabled: bool - :param frequency: Interval in seconds between test runs for this WebTest. Default value is 300. - :type frequency: int - :param timeout: Seconds until this WebTest will timeout and fail. Default value is 30. - :type timeout: int - :param web_test_kind: The kind of web test this is, valid choices are ping and multistep. - Possible values include: "ping", "multistep". - :type web_test_kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind - :param retry_enabled: Allow for retries should this WebTest fail. - :type retry_enabled: bool - :param locations: A list of where to physically run the tests from to give global coverage for - accessibility of your application. - :type locations: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestGeolocation] - :param configuration: An XML configuration specification for a WebTest. - :type configuration: - ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestPropertiesConfiguration - :ivar provisioning_state: Current state of this component, whether or not is has been - provisioned within the resource group it is defined. Users cannot change this value but are - able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. - :vartype provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'synthetic_monitor_id': {'key': 'properties.SyntheticMonitorId', 'type': 'str'}, - 'web_test_name': {'key': 'properties.Name', 'type': 'str'}, - 'description': {'key': 'properties.Description', 'type': 'str'}, - 'enabled': {'key': 'properties.Enabled', 'type': 'bool'}, - 'frequency': {'key': 'properties.Frequency', 'type': 'int'}, - 'timeout': {'key': 'properties.Timeout', 'type': 'int'}, - 'web_test_kind': {'key': 'properties.Kind', 'type': 'str'}, - 'retry_enabled': {'key': 'properties.RetryEnabled', 'type': 'bool'}, - 'locations': {'key': 'properties.Locations', 'type': '[WebTestGeolocation]'}, - 'configuration': {'key': 'properties.Configuration', 'type': 'WebTestPropertiesConfiguration'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTest, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.synthetic_monitor_id = kwargs.get('synthetic_monitor_id', None) - self.web_test_name = kwargs.get('web_test_name', None) - self.description = kwargs.get('description', None) - self.enabled = kwargs.get('enabled', None) - self.frequency = kwargs.get('frequency', 300) - self.timeout = kwargs.get('timeout', 30) - self.web_test_kind = kwargs.get('web_test_kind', None) - self.retry_enabled = kwargs.get('retry_enabled', None) - self.locations = kwargs.get('locations', None) - self.configuration = kwargs.get('configuration', None) - self.provisioning_state = None - - -class WebTestGeolocation(msrest.serialization.Model): - """Geo-physical location to run a web test from. You must specify one or more locations for the test to run from. - - :param location: Location ID for the webtest to run from. - :type location: str - """ - - _attribute_map = { - 'location': {'key': 'Id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestGeolocation, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - - -class WebTestListResult(msrest.serialization.Model): - """A list of 0 or more Application Insights web test definitions. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. Set of Application Insights web test definitions. - :type value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] - :param next_link: The link to get the next part of the returned list of web tests, should the - return set be too large for a single request. May be null. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WebTest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class WebTestPropertiesConfiguration(msrest.serialization.Model): - """An XML configuration specification for a WebTest. - - :param web_test: The XML specification of a WebTest to run against an application. - :type web_test: str - """ - - _attribute_map = { - 'web_test': {'key': 'WebTest', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestPropertiesConfiguration, self).__init__(**kwargs) - self.web_test = kwargs.get('web_test', None) - - -class WorkbookResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class Workbook(WorkbookResource): - """An Application Insights workbook definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind - :param name_properties_name: The user-defined name of the workbook. - :type name_properties_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a - string containing valid JSON. - :type serialized_data: str - :param version: This instance's version of the data model. This can change as new features are - added that can be marked workbook. - :type version: str - :param workbook_id: Internally assigned unique id of the workbook definition. - :type workbook_id: str - :param shared_type_kind: Enum indicating if this workbook definition is owned by a specific - user or is shared between all users with access to the Application Insights component. Possible - values include: "user", "shared". - :type shared_type_kind: str or - ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind - :ivar time_modified: Date and time in UTC of the last modification that was made to this - workbook definition. - :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook - definition. - :type tags_properties_tags: list[str] - :param user_id: Unique user id of the specific user that owns this workbook. - :type user_id: str - :param source_resource_id: Optional resourceId for a source resource. - :type source_resource_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'time_modified': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'workbook_id': {'key': 'properties.workbookId', 'type': 'str'}, - 'shared_type_kind': {'key': 'properties.kind', 'type': 'str'}, - 'time_modified': {'key': 'properties.timeModified', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'tags_properties_tags': {'key': 'properties.tags', 'type': '[str]'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - 'source_resource_id': {'key': 'properties.sourceResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Workbook, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.name_properties_name = kwargs.get('name_properties_name', None) - self.serialized_data = kwargs.get('serialized_data', None) - self.version = kwargs.get('version', None) - self.workbook_id = kwargs.get('workbook_id', None) - self.shared_type_kind = kwargs.get('shared_type_kind', None) - self.time_modified = None - self.category = kwargs.get('category', None) - self.tags_properties_tags = kwargs.get('tags_properties_tags', None) - self.user_id = kwargs.get('user_id', None) - self.source_resource_id = kwargs.get('source_resource_id', None) - - -class WorkbookError(msrest.serialization.Model): - """Error message body that will indicate why the operation failed. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class WorkbooksListResult(msrest.serialization.Model): - """Workbook list result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of workbooks. - :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Workbook] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Workbook]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbooksListResult, self).__init__(**kwargs) - self.value = None - - -class WorkItemConfiguration(msrest.serialization.Model): - """Work item configuration associated with an application insights resource. - - :param connector_id: Connector identifier where work item is created. - :type connector_id: str - :param config_display_name: Configuration friendly name. - :type config_display_name: str - :param is_default: Boolean value indicating whether configuration is default. - :type is_default: bool - :param id: Unique Id for work item. - :type id: str - :param config_properties: Serialized JSON object for detailed properties. - :type config_properties: str - """ - - _attribute_map = { - 'connector_id': {'key': 'ConnectorId', 'type': 'str'}, - 'config_display_name': {'key': 'ConfigDisplayName', 'type': 'str'}, - 'is_default': {'key': 'IsDefault', 'type': 'bool'}, - 'id': {'key': 'Id', 'type': 'str'}, - 'config_properties': {'key': 'ConfigProperties', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkItemConfiguration, self).__init__(**kwargs) - self.connector_id = kwargs.get('connector_id', None) - self.config_display_name = kwargs.get('config_display_name', None) - self.is_default = kwargs.get('is_default', None) - self.id = kwargs.get('id', None) - self.config_properties = kwargs.get('config_properties', None) - - -class WorkItemConfigurationError(msrest.serialization.Model): - """Error associated with trying to get work item configuration or configurations. - - :param code: Error detail code and explanation. - :type code: str - :param message: Error message. - :type message: str - :param innererror: Inner error. - :type innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'innererror': {'key': 'innererror', 'type': 'InnerError'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkItemConfigurationError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.innererror = kwargs.get('innererror', None) - - -class WorkItemConfigurationsListResult(msrest.serialization.Model): - """Work item configuration list result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of work item configurations. - :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkItemConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkItemConfigurationsListResult, self).__init__(**kwargs) - self.value = None - - -class WorkItemCreateConfiguration(msrest.serialization.Model): - """Work item configuration creation payload. - - :param connector_id: Unique connector id. - :type connector_id: str - :param connector_data_configuration: Serialized JSON object for detailed properties. - :type connector_data_configuration: str - :param validate_only: Boolean indicating validate only. - :type validate_only: bool - :param work_item_properties: Custom work item properties. - :type work_item_properties: dict[str, str] - """ - - _attribute_map = { - 'connector_id': {'key': 'ConnectorId', 'type': 'str'}, - 'connector_data_configuration': {'key': 'ConnectorDataConfiguration', 'type': 'str'}, - 'validate_only': {'key': 'ValidateOnly', 'type': 'bool'}, - 'work_item_properties': {'key': 'WorkItemProperties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkItemCreateConfiguration, self).__init__(**kwargs) - self.connector_id = kwargs.get('connector_id', None) - self.connector_data_configuration = kwargs.get('connector_data_configuration', None) - self.validate_only = kwargs.get('validate_only', None) - self.work_item_properties = kwargs.get('work_item_properties', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py index ebc8764aab1ac..99e987ed11650 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/models/_models_py3.py @@ -18,18 +18,18 @@ class Annotation(msrest.serialization.Model): """Annotation associated with an application insights resource. - :param annotation_name: Name of annotation. - :type annotation_name: str - :param category: Category of annotation, free form. - :type category: str - :param event_time: Time when event occurred. - :type event_time: ~datetime.datetime - :param id: Unique Id for annotation. - :type id: str - :param properties: Serialized JSON object for detailed properties. - :type properties: str - :param related_annotation: Related parent annotation if any. - :type related_annotation: str + :ivar annotation_name: Name of annotation. + :vartype annotation_name: str + :ivar category: Category of annotation, free form. + :vartype category: str + :ivar event_time: Time when event occurred. + :vartype event_time: ~datetime.datetime + :ivar id: Unique Id for annotation. + :vartype id: str + :ivar properties: Serialized JSON object for detailed properties. + :vartype properties: str + :ivar related_annotation: Related parent annotation if any. + :vartype related_annotation: str """ _attribute_map = { @@ -52,6 +52,20 @@ def __init__( related_annotation: Optional[str] = "null", **kwargs ): + """ + :keyword annotation_name: Name of annotation. + :paramtype annotation_name: str + :keyword category: Category of annotation, free form. + :paramtype category: str + :keyword event_time: Time when event occurred. + :paramtype event_time: ~datetime.datetime + :keyword id: Unique Id for annotation. + :paramtype id: str + :keyword properties: Serialized JSON object for detailed properties. + :paramtype properties: str + :keyword related_annotation: Related parent annotation if any. + :paramtype related_annotation: str + """ super(Annotation, self).__init__(**kwargs) self.annotation_name = annotation_name self.category = category @@ -64,12 +78,12 @@ def __init__( class AnnotationError(msrest.serialization.Model): """Error associated with trying to create annotation with Id that already exist. - :param code: Error detail code and explanation. - :type code: str - :param message: Error message. - :type message: str - :param innererror: Inner error. - :type innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError + :ivar code: Error detail code and explanation. + :vartype code: str + :ivar message: Error message. + :vartype message: str + :ivar innererror: Inner error. + :vartype innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError """ _attribute_map = { @@ -86,6 +100,14 @@ def __init__( innererror: Optional["InnerError"] = None, **kwargs ): + """ + :keyword code: Error detail code and explanation. + :paramtype code: str + :keyword message: Error message. + :paramtype message: str + :keyword innererror: Inner error. + :paramtype innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError + """ super(AnnotationError, self).__init__(**kwargs) self.code = code self.message = message @@ -113,6 +135,8 @@ def __init__( self, **kwargs ): + """ + """ super(AnnotationsListResult, self).__init__(**kwargs) self.value = None @@ -120,12 +144,12 @@ def __init__( class APIKeyRequest(msrest.serialization.Model): """An Application Insights component API Key creation request definition. - :param name: The name of the API Key. - :type name: str - :param linked_read_properties: The read access rights of this API Key. - :type linked_read_properties: list[str] - :param linked_write_properties: The write access rights of this API Key. - :type linked_write_properties: list[str] + :ivar name: The name of the API Key. + :vartype name: str + :ivar linked_read_properties: The read access rights of this API Key. + :vartype linked_read_properties: list[str] + :ivar linked_write_properties: The write access rights of this API Key. + :vartype linked_write_properties: list[str] """ _attribute_map = { @@ -142,6 +166,14 @@ def __init__( linked_write_properties: Optional[List[str]] = None, **kwargs ): + """ + :keyword name: The name of the API Key. + :paramtype name: str + :keyword linked_read_properties: The read access rights of this API Key. + :paramtype linked_read_properties: list[str] + :keyword linked_write_properties: The write access rights of this API Key. + :paramtype linked_write_properties: list[str] + """ super(APIKeyRequest, self).__init__(**kwargs) self.name = name self.linked_read_properties = linked_read_properties @@ -161,10 +193,10 @@ class ComponentsResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -189,6 +221,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ComponentsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -210,31 +248,32 @@ class ApplicationInsightsComponent(ComponentsResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. The kind of application that this component refers to, used to customize + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone. - :type kind: str + :vartype kind: str :ivar application_id: The unique ID of your application. This field mirrors the 'Name' field and cannot be changed. :vartype application_id: str :ivar app_id: Application Insights Unique ID for your Application. :vartype app_id: str - :param application_type: Type of application being monitored. Possible values include: "web", + :ivar application_type: Type of application being monitored. Possible values include: "web", "other". Default value: "web". - :type application_type: str or + :vartype application_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationType - :param flow_type: Used by the Application Insights system to determine what kind of flow this + :ivar flow_type: Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". - :type flow_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.FlowType - :param request_source: Describes what tool created this Application Insights component. + :vartype flow_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.FlowType + :ivar request_source: Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. Possible values include: "rest". Default value: "rest". - :type request_source: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.RequestSource + :vartype request_source: str or + ~azure.mgmt.applicationinsights.v2015_05_01.models.RequestSource :ivar instrumentation_key: Application Insights Instrumentation key. A read-only value that applications can use to identify the destination for all telemetry sent to Azure Application Insights. This value will be supplied upon construction of each new Application Insights @@ -244,9 +283,9 @@ class ApplicationInsightsComponent(ComponentsResource): :vartype creation_date: ~datetime.datetime :ivar tenant_id: Azure Tenant Id. :vartype tenant_id: str - :param hockey_app_id: The unique application ID created when a new application is added to + :ivar hockey_app_id: The unique application ID created when a new application is added to HockeyApp, used for communications with HockeyApp. - :type hockey_app_id: str + :vartype hockey_app_id: str :ivar hockey_app_token: Token used to authenticate communications with between Application Insights and HockeyApp. :vartype hockey_app_token: str @@ -254,24 +293,25 @@ class ApplicationInsightsComponent(ComponentsResource): provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. :vartype provisioning_state: str - :param sampling_percentage: Percentage of the data produced by the application being monitored + :ivar sampling_percentage: Percentage of the data produced by the application being monitored that is being sampled for Application Insights telemetry. - :type sampling_percentage: float + :vartype sampling_percentage: float :ivar connection_string: Application Insights component connection string. :vartype connection_string: str - :param retention_in_days: Retention period in days. - :type retention_in_days: int - :param disable_ip_masking: Disable IP masking. - :type disable_ip_masking: bool - :param immediate_purge_data_on30_days: Purge data immediately after 30 days. - :type immediate_purge_data_on30_days: bool + :ivar retention_in_days: Retention period in days. + :vartype retention_in_days: int + :ivar disable_ip_masking: Disable IP masking. + :vartype disable_ip_masking: bool + :ivar immediate_purge_data_on30_days: Purge data immediately after 30 days. + :vartype immediate_purge_data_on30_days: bool :ivar private_link_scoped_resources: List of linked private link scope resources. :vartype private_link_scoped_resources: list[~azure.mgmt.applicationinsights.v2015_05_01.models.PrivateLinkScopedResource] - :param ingestion_mode: Indicates the flow of the ingestion. Possible values include: + :ivar ingestion_mode: Indicates the flow of the ingestion. Possible values include: "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default value: "ApplicationInsights". - :type ingestion_mode: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.IngestionMode + :vartype ingestion_mode: str or + ~azure.mgmt.applicationinsights.v2015_05_01.models.IngestionMode """ _validation = { @@ -335,6 +375,46 @@ def __init__( ingestion_mode: Optional[Union[str, "IngestionMode"]] = "ApplicationInsights", **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Required. The kind of application that this component refers to, used to + customize UI. This value is a freeform string, values should typically be one of the following: + web, ios, other, store, java, phone. + :paramtype kind: str + :keyword application_type: Type of application being monitored. Possible values include: "web", + "other". Default value: "web". + :paramtype application_type: str or + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationType + :keyword flow_type: Used by the Application Insights system to determine what kind of flow this + component was created by. This is to be set to 'Bluefield' when creating/updating a component + via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". + :paramtype flow_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.FlowType + :keyword request_source: Describes what tool created this Application Insights component. + Customers using this API should set this to the default 'rest'. Possible values include: + "rest". Default value: "rest". + :paramtype request_source: str or + ~azure.mgmt.applicationinsights.v2015_05_01.models.RequestSource + :keyword hockey_app_id: The unique application ID created when a new application is added to + HockeyApp, used for communications with HockeyApp. + :paramtype hockey_app_id: str + :keyword sampling_percentage: Percentage of the data produced by the application being + monitored that is being sampled for Application Insights telemetry. + :paramtype sampling_percentage: float + :keyword retention_in_days: Retention period in days. + :paramtype retention_in_days: int + :keyword disable_ip_masking: Disable IP masking. + :paramtype disable_ip_masking: bool + :keyword immediate_purge_data_on30_days: Purge data immediately after 30 days. + :paramtype immediate_purge_data_on30_days: bool + :keyword ingestion_mode: Indicates the flow of the ingestion. Possible values include: + "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default + value: "ApplicationInsights". + :paramtype ingestion_mode: str or + ~azure.mgmt.applicationinsights.v2015_05_01.models.IngestionMode + """ super(ApplicationInsightsComponent, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.application_id = None @@ -362,29 +442,29 @@ class ApplicationInsightsComponentAnalyticsItem(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: Internally assigned unique id of the item definition. - :type id: str - :param name: The user-defined name of the item. - :type name: str - :param content: The content of this item. - :type content: str + :ivar id: Internally assigned unique id of the item definition. + :vartype id: str + :ivar name: The user-defined name of the item. + :vartype name: str + :ivar content: The content of this item. + :vartype content: str :ivar version: This instance's version of the data model. This can change as new features are added. :vartype version: str - :param scope: Enum indicating if this item definition is owned by a specific user or is shared + :ivar scope: Enum indicating if this item definition is owned by a specific user or is shared between all users with access to the Application Insights component. Possible values include: "shared", "user". - :type scope: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScope - :param type: Enum indicating the type of the Analytics item. Possible values include: "query", - "function", "folder", "recent". - :type type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemType + :vartype scope: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScope + :ivar type: Enum indicating the type of the Analytics item. Possible values include: "none", + "query", "recent", "function". + :vartype type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemType :ivar time_created: Date and time in UTC when this item was created. :vartype time_created: str :ivar time_modified: Date and time in UTC of the last modification that was made to this item. :vartype time_modified: str - :param properties: A set of properties that can be defined in the context of a specific item + :ivar properties: A set of properties that can be defined in the context of a specific item type. Each type may have its own properties. - :type properties: + :vartype properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItemProperties """ @@ -417,6 +497,25 @@ def __init__( properties: Optional["ApplicationInsightsComponentAnalyticsItemProperties"] = None, **kwargs ): + """ + :keyword id: Internally assigned unique id of the item definition. + :paramtype id: str + :keyword name: The user-defined name of the item. + :paramtype name: str + :keyword content: The content of this item. + :paramtype content: str + :keyword scope: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Possible values + include: "shared", "user". + :paramtype scope: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScope + :keyword type: Enum indicating the type of the Analytics item. Possible values include: "none", + "query", "recent", "function". + :paramtype type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemType + :keyword properties: A set of properties that can be defined in the context of a specific item + type. Each type may have its own properties. + :paramtype properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItemProperties + """ super(ApplicationInsightsComponentAnalyticsItem, self).__init__(**kwargs) self.id = id self.name = name @@ -432,8 +531,8 @@ def __init__( class ApplicationInsightsComponentAnalyticsItemProperties(msrest.serialization.Model): """A set of properties that can be defined in the context of a specific item type. Each type may have its own properties. - :param function_alias: A function alias, used when the type of the item is Function. - :type function_alias: str + :ivar function_alias: A function alias, used when the type of the item is Function. + :vartype function_alias: str """ _attribute_map = { @@ -446,6 +545,10 @@ def __init__( function_alias: Optional[str] = None, **kwargs ): + """ + :keyword function_alias: A function alias, used when the type of the item is Function. + :paramtype function_alias: str + """ super(ApplicationInsightsComponentAnalyticsItemProperties, self).__init__(**kwargs) self.function_alias = function_alias @@ -460,14 +563,14 @@ class ApplicationInsightsComponentAPIKey(msrest.serialization.Model): :vartype id: str :ivar api_key: The API key value. It will be only return once when the API Key was created. :vartype api_key: str - :param created_date: The create date of this API key. - :type created_date: str - :param name: The name of the API key. - :type name: str - :param linked_read_properties: The read access rights of this API Key. - :type linked_read_properties: list[str] - :param linked_write_properties: The write access rights of this API Key. - :type linked_write_properties: list[str] + :ivar created_date: The create date of this API key. + :vartype created_date: str + :ivar name: The name of the API key. + :vartype name: str + :ivar linked_read_properties: The read access rights of this API Key. + :vartype linked_read_properties: list[str] + :ivar linked_write_properties: The write access rights of this API Key. + :vartype linked_write_properties: list[str] """ _validation = { @@ -493,6 +596,16 @@ def __init__( linked_write_properties: Optional[List[str]] = None, **kwargs ): + """ + :keyword created_date: The create date of this API key. + :paramtype created_date: str + :keyword name: The name of the API key. + :paramtype name: str + :keyword linked_read_properties: The read access rights of this API Key. + :paramtype linked_read_properties: list[str] + :keyword linked_write_properties: The write access rights of this API Key. + :paramtype linked_write_properties: list[str] + """ super(ApplicationInsightsComponentAPIKey, self).__init__(**kwargs) self.id = None self.api_key = None @@ -507,8 +620,8 @@ class ApplicationInsightsComponentAPIKeyListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of API Key definitions. - :type value: + :ivar value: Required. List of API Key definitions. + :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey] """ @@ -526,6 +639,11 @@ def __init__( value: List["ApplicationInsightsComponentAPIKey"], **kwargs ): + """ + :keyword value: Required. List of API Key definitions. + :paramtype value: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKey] + """ super(ApplicationInsightsComponentAPIKeyListResult, self).__init__(**kwargs) self.value = value @@ -552,6 +670,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApplicationInsightsComponentAvailableFeatures, self).__init__(**kwargs) self.result = None @@ -559,12 +679,12 @@ def __init__( class ApplicationInsightsComponentBillingFeatures(msrest.serialization.Model): """An Application Insights component billing features. - :param data_volume_cap: An Application Insights component daily data volume cap. - :type data_volume_cap: + :ivar data_volume_cap: An Application Insights component daily data volume cap. + :vartype data_volume_cap: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentDataVolumeCap - :param current_billing_features: Current enabled pricing plan. When the component is in the + :ivar current_billing_features: Current enabled pricing plan. When the component is in the Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'. - :type current_billing_features: list[str] + :vartype current_billing_features: list[str] """ _attribute_map = { @@ -579,6 +699,14 @@ def __init__( current_billing_features: Optional[List[str]] = None, **kwargs ): + """ + :keyword data_volume_cap: An Application Insights component daily data volume cap. + :paramtype data_volume_cap: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentDataVolumeCap + :keyword current_billing_features: Current enabled pricing plan. When the component is in the + Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'. + :paramtype current_billing_features: list[str] + """ super(ApplicationInsightsComponentBillingFeatures, self).__init__(**kwargs) self.data_volume_cap = data_volume_cap self.current_billing_features = current_billing_features @@ -589,17 +717,17 @@ class ApplicationInsightsComponentDataVolumeCap(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param cap: Daily data volume cap in GB. - :type cap: float + :ivar cap: Daily data volume cap in GB. + :vartype cap: float :ivar reset_time: Daily data volume cap UTC reset hour. :vartype reset_time: int - :param warning_threshold: Reserved, not used for now. - :type warning_threshold: int - :param stop_send_notification_when_hit_threshold: Reserved, not used for now. - :type stop_send_notification_when_hit_threshold: bool - :param stop_send_notification_when_hit_cap: Do not send a notification email when the daily - data volume cap is met. - :type stop_send_notification_when_hit_cap: bool + :ivar warning_threshold: Reserved, not used for now. + :vartype warning_threshold: int + :ivar stop_send_notification_when_hit_threshold: Reserved, not used for now. + :vartype stop_send_notification_when_hit_threshold: bool + :ivar stop_send_notification_when_hit_cap: Do not send a notification email when the daily data + volume cap is met. + :vartype stop_send_notification_when_hit_cap: bool :ivar max_history_cap: Maximum daily data volume cap that the user can set for this component. :vartype max_history_cap: float """ @@ -627,6 +755,17 @@ def __init__( stop_send_notification_when_hit_cap: Optional[bool] = None, **kwargs ): + """ + :keyword cap: Daily data volume cap in GB. + :paramtype cap: float + :keyword warning_threshold: Reserved, not used for now. + :paramtype warning_threshold: int + :keyword stop_send_notification_when_hit_threshold: Reserved, not used for now. + :paramtype stop_send_notification_when_hit_threshold: bool + :keyword stop_send_notification_when_hit_cap: Do not send a notification email when the daily + data volume cap is met. + :paramtype stop_send_notification_when_hit_cap: bool + """ super(ApplicationInsightsComponentDataVolumeCap, self).__init__(**kwargs) self.cap = cap self.reset_time = None @@ -646,10 +785,10 @@ class ApplicationInsightsComponentExportConfiguration(msrest.serialization.Model :vartype export_id: str :ivar instrumentation_key: The instrumentation key of the Application Insights component. :vartype instrumentation_key: str - :param record_types: This comma separated list of document types that will be exported. The + :ivar record_types: This comma separated list of document types that will be exported. The possible values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. - :type record_types: str + :vartype record_types: str :ivar application_name: The name of the Application Insights component. :vartype application_name: str :ivar subscription_id: The subscription of the Application Insights component. @@ -669,8 +808,8 @@ class ApplicationInsightsComponentExportConfiguration(msrest.serialization.Model :vartype is_user_enabled: str :ivar last_user_update: Last time the Continuous Export configuration was updated. :vartype last_user_update: str - :param notification_queue_enabled: Deprecated. - :type notification_queue_enabled: str + :ivar notification_queue_enabled: Deprecated. + :vartype notification_queue_enabled: str :ivar export_status: This indicates current Continuous Export configuration status. The possible values are 'Preparing', 'Success', 'Failure'. :vartype export_status: str @@ -737,6 +876,14 @@ def __init__( notification_queue_enabled: Optional[str] = None, **kwargs ): + """ + :keyword record_types: This comma separated list of document types that will be exported. The + possible values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', + 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + :paramtype record_types: str + :keyword notification_queue_enabled: Deprecated. + :paramtype notification_queue_enabled: str + """ super(ApplicationInsightsComponentExportConfiguration, self).__init__(**kwargs) self.export_id = None self.instrumentation_key = None @@ -762,29 +909,29 @@ def __init__( class ApplicationInsightsComponentExportRequest(msrest.serialization.Model): """An Application Insights component Continuous Export configuration request definition. - :param record_types: The document types to be exported, as comma separated values. Allowed + :ivar record_types: The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. - :type record_types: str - :param destination_type: The Continuous Export destination type. This has to be 'Blob'. - :type destination_type: str - :param destination_address: The SAS URL for the destination storage container. It must grant + :vartype record_types: str + :ivar destination_type: The Continuous Export destination type. This has to be 'Blob'. + :vartype destination_type: str + :ivar destination_address: The SAS URL for the destination storage container. It must grant write permission. - :type destination_address: str - :param is_enabled: Set to 'true' to create a Continuous Export configuration as enabled, + :vartype destination_address: str + :ivar is_enabled: Set to 'true' to create a Continuous Export configuration as enabled, otherwise set it to 'false'. - :type is_enabled: str - :param notification_queue_enabled: Deprecated. - :type notification_queue_enabled: str - :param notification_queue_uri: Deprecated. - :type notification_queue_uri: str - :param destination_storage_subscription_id: The subscription ID of the destination storage + :vartype is_enabled: str + :ivar notification_queue_enabled: Deprecated. + :vartype notification_queue_enabled: str + :ivar notification_queue_uri: Deprecated. + :vartype notification_queue_uri: str + :ivar destination_storage_subscription_id: The subscription ID of the destination storage container. - :type destination_storage_subscription_id: str - :param destination_storage_location_id: The location ID of the destination storage container. - :type destination_storage_location_id: str - :param destination_account_id: The name of destination storage account. - :type destination_account_id: str + :vartype destination_storage_subscription_id: str + :ivar destination_storage_location_id: The location ID of the destination storage container. + :vartype destination_storage_location_id: str + :ivar destination_account_id: The name of destination storage account. + :vartype destination_account_id: str """ _attribute_map = { @@ -813,6 +960,31 @@ def __init__( destination_account_id: Optional[str] = None, **kwargs ): + """ + :keyword record_types: The document types to be exported, as comma separated values. Allowed + values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', + 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + :paramtype record_types: str + :keyword destination_type: The Continuous Export destination type. This has to be 'Blob'. + :paramtype destination_type: str + :keyword destination_address: The SAS URL for the destination storage container. It must grant + write permission. + :paramtype destination_address: str + :keyword is_enabled: Set to 'true' to create a Continuous Export configuration as enabled, + otherwise set it to 'false'. + :paramtype is_enabled: str + :keyword notification_queue_enabled: Deprecated. + :paramtype notification_queue_enabled: str + :keyword notification_queue_uri: Deprecated. + :paramtype notification_queue_uri: str + :keyword destination_storage_subscription_id: The subscription ID of the destination storage + container. + :paramtype destination_storage_subscription_id: str + :keyword destination_storage_location_id: The location ID of the destination storage container. + :paramtype destination_storage_location_id: str + :keyword destination_account_id: The name of destination storage account. + :paramtype destination_account_id: str + """ super(ApplicationInsightsComponentExportRequest, self).__init__(**kwargs) self.record_types = record_types self.destination_type = destination_type @@ -830,33 +1002,33 @@ class ApplicationInsightsComponentFavorite(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The user-defined name of the favorite. - :type name: str - :param config: Configuration of this particular favorite, which are driven by the Azure portal + :ivar name: The user-defined name of the favorite. + :vartype name: str + :ivar config: Configuration of this particular favorite, which are driven by the Azure portal UX. Configuration data is a string containing valid JSON. - :type config: str - :param version: This instance's version of the data model. This can change as new features are + :vartype config: str + :ivar version: This instance's version of the data model. This can change as new features are added that can be marked favorite. Current examples include MetricsExplorer (ME) and Search. - :type version: str + :vartype version: str :ivar favorite_id: Internally assigned unique id of the favorite definition. :vartype favorite_id: str - :param favorite_type: Enum indicating if this favorite definition is owned by a specific user - or is shared between all users with access to the Application Insights component. Possible - values include: "shared", "user". - :type favorite_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.FavoriteType - :param source_type: The source of the favorite definition. - :type source_type: str + :ivar favorite_type: Enum indicating if this favorite definition is owned by a specific user or + is shared between all users with access to the Application Insights component. Possible values + include: "shared", "user". + :vartype favorite_type: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.FavoriteType + :ivar source_type: The source of the favorite definition. + :vartype source_type: str :ivar time_modified: Date and time in UTC of the last modification that was made to this favorite definition. :vartype time_modified: str - :param tags: A set of tags. A list of 0 or more tags that are associated with this favorite + :ivar tags: A set of tags. A list of 0 or more tags that are associated with this favorite definition. - :type tags: list[str] - :param category: Favorite category, as defined by the user at creation time. - :type category: str - :param is_generated_from_template: Flag denoting wether or not this favorite was generated from + :vartype tags: list[str] + :ivar category: Favorite category, as defined by the user at creation time. + :vartype category: str + :ivar is_generated_from_template: Flag denoting wether or not this favorite was generated from a template. - :type is_generated_from_template: bool + :vartype is_generated_from_template: bool :ivar user_id: Unique user id of the specific user that owns this favorite. :vartype user_id: str """ @@ -894,6 +1066,32 @@ def __init__( is_generated_from_template: Optional[bool] = None, **kwargs ): + """ + :keyword name: The user-defined name of the favorite. + :paramtype name: str + :keyword config: Configuration of this particular favorite, which are driven by the Azure + portal UX. Configuration data is a string containing valid JSON. + :paramtype config: str + :keyword version: This instance's version of the data model. This can change as new features + are added that can be marked favorite. Current examples include MetricsExplorer (ME) and + Search. + :paramtype version: str + :keyword favorite_type: Enum indicating if this favorite definition is owned by a specific user + or is shared between all users with access to the Application Insights component. Possible + values include: "shared", "user". + :paramtype favorite_type: str or + ~azure.mgmt.applicationinsights.v2015_05_01.models.FavoriteType + :keyword source_type: The source of the favorite definition. + :paramtype source_type: str + :keyword tags: A set of tags. A list of 0 or more tags that are associated with this favorite + definition. + :paramtype tags: list[str] + :keyword category: Favorite category, as defined by the user at creation time. + :paramtype category: str + :keyword is_generated_from_template: Flag denoting wether or not this favorite was generated + from a template. + :paramtype is_generated_from_template: bool + """ super(ApplicationInsightsComponentFavorite, self).__init__(**kwargs) self.name = name self.config = config @@ -962,6 +1160,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApplicationInsightsComponentFeature, self).__init__(**kwargs) self.feature_name = None self.meter_id = None @@ -1055,6 +1255,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApplicationInsightsComponentFeatureCapabilities, self).__init__(**kwargs) self.support_export_data = None self.burst_throttle_policy = None @@ -1115,6 +1317,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApplicationInsightsComponentFeatureCapability, self).__init__(**kwargs) self.name = None self.description = None @@ -1129,12 +1333,12 @@ class ApplicationInsightsComponentListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of Application Insights component definitions. - :type value: + :ivar value: Required. List of Application Insights component definitions. + :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent] - :param next_link: The URI to get the next set of Application Insights component definitions if + :ivar next_link: The URI to get the next set of Application Insights component definitions if too many components where returned in the result set. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -1153,6 +1357,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. List of Application Insights component definitions. + :paramtype value: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent] + :keyword next_link: The URI to get the next set of Application Insights component definitions + if too many components where returned in the result set. + :paramtype next_link: str + """ super(ApplicationInsightsComponentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1161,20 +1373,20 @@ def __init__( class ApplicationInsightsComponentProactiveDetectionConfiguration(msrest.serialization.Model): """Properties that define a ProactiveDetection configuration. - :param name: The rule name. - :type name: str - :param enabled: A flag that indicates whether this rule is enabled by the user. - :type enabled: bool - :param send_emails_to_subscription_owners: A flag that indicated whether notifications on this + :ivar name: The rule name. + :vartype name: str + :ivar enabled: A flag that indicates whether this rule is enabled by the user. + :vartype enabled: bool + :ivar send_emails_to_subscription_owners: A flag that indicated whether notifications on this rule should be sent to subscription owners. - :type send_emails_to_subscription_owners: bool - :param custom_emails: Custom email addresses for this rule notifications. - :type custom_emails: list[str] - :param last_updated_time: The last time this rule was updated. - :type last_updated_time: str - :param rule_definitions: Static definitions of the ProactiveDetection configuration rule (same + :vartype send_emails_to_subscription_owners: bool + :ivar custom_emails: Custom email addresses for this rule notifications. + :vartype custom_emails: list[str] + :ivar last_updated_time: The last time this rule was updated. + :vartype last_updated_time: str + :ivar rule_definitions: Static definitions of the ProactiveDetection configuration rule (same values for all components). - :type rule_definitions: + :vartype rule_definitions: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions """ @@ -1198,6 +1410,23 @@ def __init__( rule_definitions: Optional["ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions"] = None, **kwargs ): + """ + :keyword name: The rule name. + :paramtype name: str + :keyword enabled: A flag that indicates whether this rule is enabled by the user. + :paramtype enabled: bool + :keyword send_emails_to_subscription_owners: A flag that indicated whether notifications on + this rule should be sent to subscription owners. + :paramtype send_emails_to_subscription_owners: bool + :keyword custom_emails: Custom email addresses for this rule notifications. + :paramtype custom_emails: list[str] + :keyword last_updated_time: The last time this rule was updated. + :paramtype last_updated_time: str + :keyword rule_definitions: Static definitions of the ProactiveDetection configuration rule + (same values for all components). + :paramtype rule_definitions: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions + """ super(ApplicationInsightsComponentProactiveDetectionConfiguration, self).__init__(**kwargs) self.name = name self.enabled = enabled @@ -1210,23 +1439,23 @@ def __init__( class ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions(msrest.serialization.Model): """Static definitions of the ProactiveDetection configuration rule (same values for all components). - :param name: The rule name. - :type name: str - :param display_name: The rule name as it is displayed in UI. - :type display_name: str - :param description: The rule description. - :type description: str - :param help_url: URL which displays additional info about the proactive detection rule. - :type help_url: str - :param is_hidden: A flag indicating whether the rule is hidden (from the UI). - :type is_hidden: bool - :param is_enabled_by_default: A flag indicating whether the rule is enabled by default. - :type is_enabled_by_default: bool - :param is_in_preview: A flag indicating whether the rule is in preview. - :type is_in_preview: bool - :param supports_email_notifications: A flag indicating whether email notifications are - supported for detections for this rule. - :type supports_email_notifications: bool + :ivar name: The rule name. + :vartype name: str + :ivar display_name: The rule name as it is displayed in UI. + :vartype display_name: str + :ivar description: The rule description. + :vartype description: str + :ivar help_url: URL which displays additional info about the proactive detection rule. + :vartype help_url: str + :ivar is_hidden: A flag indicating whether the rule is hidden (from the UI). + :vartype is_hidden: bool + :ivar is_enabled_by_default: A flag indicating whether the rule is enabled by default. + :vartype is_enabled_by_default: bool + :ivar is_in_preview: A flag indicating whether the rule is in preview. + :vartype is_in_preview: bool + :ivar supports_email_notifications: A flag indicating whether email notifications are supported + for detections for this rule. + :vartype supports_email_notifications: bool """ _attribute_map = { @@ -1253,6 +1482,25 @@ def __init__( supports_email_notifications: Optional[bool] = None, **kwargs ): + """ + :keyword name: The rule name. + :paramtype name: str + :keyword display_name: The rule name as it is displayed in UI. + :paramtype display_name: str + :keyword description: The rule description. + :paramtype description: str + :keyword help_url: URL which displays additional info about the proactive detection rule. + :paramtype help_url: str + :keyword is_hidden: A flag indicating whether the rule is hidden (from the UI). + :paramtype is_hidden: bool + :keyword is_enabled_by_default: A flag indicating whether the rule is enabled by default. + :paramtype is_enabled_by_default: bool + :keyword is_in_preview: A flag indicating whether the rule is in preview. + :paramtype is_in_preview: bool + :keyword supports_email_notifications: A flag indicating whether email notifications are + supported for detections for this rule. + :paramtype supports_email_notifications: bool + """ super(ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -1295,6 +1543,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApplicationInsightsComponentQuotaStatus, self).__init__(**kwargs) self.app_id = None self.should_be_throttled = None @@ -1326,6 +1576,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApplicationInsightsComponentWebTestLocation, self).__init__(**kwargs) self.display_name = None self.tag = None @@ -1336,8 +1588,8 @@ class ApplicationInsightsWebTestLocationsListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of web test locations. - :type value: + :ivar value: Required. List of web test locations. + :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentWebTestLocation] """ @@ -1355,6 +1607,11 @@ def __init__( value: List["ApplicationInsightsComponentWebTestLocation"], **kwargs ): + """ + :keyword value: Required. List of web test locations. + :paramtype value: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentWebTestLocation] + """ super(ApplicationInsightsWebTestLocationsListResult, self).__init__(**kwargs) self.value = value @@ -1364,11 +1621,11 @@ class ComponentPurgeBody(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param table: Required. Table from which to purge data. - :type table: str - :param filters: Required. The set of columns and filters (queries) to run over them to purge - the resulting data. - :type filters: + :ivar table: Required. Table from which to purge data. + :vartype table: str + :ivar filters: Required. The set of columns and filters (queries) to run over them to purge the + resulting data. + :vartype filters: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeBodyFilters] """ @@ -1389,6 +1646,14 @@ def __init__( filters: List["ComponentPurgeBodyFilters"], **kwargs ): + """ + :keyword table: Required. Table from which to purge data. + :paramtype table: str + :keyword filters: Required. The set of columns and filters (queries) to run over them to purge + the resulting data. + :paramtype filters: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ComponentPurgeBodyFilters] + """ super(ComponentPurgeBody, self).__init__(**kwargs) self.table = table self.filters = filters @@ -1397,18 +1662,18 @@ def __init__( class ComponentPurgeBodyFilters(msrest.serialization.Model): """User-defined filters to return data which will be purged from the table. - :param column: The column of the table over which the given query should run. - :type column: str - :param operator: A query operator to evaluate over the provided column and value(s). Supported + :ivar column: The column of the table over which the given query should run. + :vartype column: str + :ivar operator: A query operator to evaluate over the provided column and value(s). Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would in a KQL query. - :type operator: str - :param value: the value for the operator to function over. This can be a number (e.g., > 100), - a string (timestamp >= '2017-09-01') or array of values. - :type value: any - :param key: When filtering over custom dimensions, this key will be used as the name of the + :vartype operator: str + :ivar value: the value for the operator to function over. This can be a number (e.g., > 100), a + string (timestamp >= '2017-09-01') or array of values. + :vartype value: any + :ivar key: When filtering over custom dimensions, this key will be used as the name of the custom dimension. - :type key: str + :vartype key: str """ _attribute_map = { @@ -1427,6 +1692,20 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword column: The column of the table over which the given query should run. + :paramtype column: str + :keyword operator: A query operator to evaluate over the provided column and value(s). + Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as + they would in a KQL query. + :paramtype operator: str + :keyword value: the value for the operator to function over. This can be a number (e.g., > + 100), a string (timestamp >= '2017-09-01') or array of values. + :paramtype value: any + :keyword key: When filtering over custom dimensions, this key will be used as the name of the + custom dimension. + :paramtype key: str + """ super(ComponentPurgeBodyFilters, self).__init__(**kwargs) self.column = column self.operator = operator @@ -1439,9 +1718,9 @@ class ComponentPurgeResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param operation_id: Required. Id to use when querying for status for a particular purge + :ivar operation_id: Required. Id to use when querying for status for a particular purge operation. - :type operation_id: str + :vartype operation_id: str """ _validation = { @@ -1458,6 +1737,11 @@ def __init__( operation_id: str, **kwargs ): + """ + :keyword operation_id: Required. Id to use when querying for status for a particular purge + operation. + :paramtype operation_id: str + """ super(ComponentPurgeResponse, self).__init__(**kwargs) self.operation_id = operation_id @@ -1467,9 +1751,9 @@ class ComponentPurgeStatusResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the operation represented by the requested Id. Possible + :ivar status: Required. Status of the operation represented by the requested Id. Possible values include: "pending", "completed". - :type status: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.PurgeState + :vartype status: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.PurgeState """ _validation = { @@ -1486,6 +1770,11 @@ def __init__( status: Union[str, "PurgeState"], **kwargs ): + """ + :keyword status: Required. Status of the operation represented by the requested Id. Possible + values include: "pending", "completed". + :paramtype status: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.PurgeState + """ super(ComponentPurgeStatusResponse, self).__init__(**kwargs) self.status = status @@ -1493,12 +1782,12 @@ def __init__( class ErrorFieldContract(msrest.serialization.Model): """Error Field contract. - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str """ _attribute_map = { @@ -1515,6 +1804,14 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword code: Property level error code. + :paramtype code: str + :keyword message: Human-readable representation of property-level error. + :paramtype message: str + :keyword target: Property name. + :paramtype target: str + """ super(ErrorFieldContract, self).__init__(**kwargs) self.code = code self.message = message @@ -1524,10 +1821,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -1542,6 +1839,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -1550,10 +1853,10 @@ def __init__( class InnerError(msrest.serialization.Model): """Inner error. - :param diagnosticcontext: Provides correlation for request. - :type diagnosticcontext: str - :param time: Request time. - :type time: ~datetime.datetime + :ivar diagnosticcontext: Provides correlation for request. + :vartype diagnosticcontext: str + :ivar time: Request time. + :vartype time: ~datetime.datetime """ _attribute_map = { @@ -1568,6 +1871,12 @@ def __init__( time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword diagnosticcontext: Provides correlation for request. + :paramtype diagnosticcontext: str + :keyword time: Request time. + :paramtype time: ~datetime.datetime + """ super(InnerError, self).__init__(**kwargs) self.diagnosticcontext = diagnosticcontext self.time = time @@ -1576,12 +1885,12 @@ def __init__( class LinkProperties(msrest.serialization.Model): """Contains a sourceId and workbook resource id to link two resources. - :param source_id: The source Azure resource id. - :type source_id: str - :param target_id: The workbook Azure resource id. - :type target_id: str - :param category: The category of workbook. - :type category: str + :ivar source_id: The source Azure resource id. + :vartype source_id: str + :ivar target_id: The workbook Azure resource id. + :vartype target_id: str + :ivar category: The category of workbook. + :vartype category: str """ _attribute_map = { @@ -1598,6 +1907,14 @@ def __init__( category: Optional[str] = None, **kwargs ): + """ + :keyword source_id: The source Azure resource id. + :paramtype source_id: str + :keyword target_id: The workbook Azure resource id. + :paramtype target_id: str + :keyword category: The category of workbook. + :paramtype category: str + """ super(LinkProperties, self).__init__(**kwargs) self.source_id = source_id self.target_id = target_id @@ -1607,16 +1924,16 @@ def __init__( class MyWorkbookResource(msrest.serialization.Model): """An azure resource object. - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1637,6 +1954,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword id: Azure resource Id. + :paramtype id: str + :keyword name: Azure resource name. + :paramtype name: str + :keyword type: Azure resource type. + :paramtype type: str + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(MyWorkbookResource, self).__init__(**kwargs) self.id = id self.name = name @@ -1650,39 +1979,39 @@ class MyWorkbook(MyWorkbookResource): Variables are only populated by the server, and will be ignored when sending a request. - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind - :param display_name: The user-defined name of the private workbook. - :type display_name: str - :param serialized_data: Configuration of this particular private workbook. Configuration data - is a string containing valid JSON. - :type serialized_data: str - :param version: This instance's version of the data model. This can change as new features are + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind + :ivar display_name: The user-defined name of the private workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular private workbook. Configuration data is + a string containing valid JSON. + :vartype serialized_data: str + :ivar version: This instance's version of the data model. This can change as new features are added that can be marked private workbook. - :type version: str + :vartype version: str :ivar time_modified: Date and time in UTC of the last modification that was made to this private workbook definition. :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this private + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: A list of 0 or more tags that are associated with this private workbook definition. - :type tags_properties_tags: list[str] + :vartype tags_properties_tags: list[str] :ivar user_id: Unique user id of the specific user that owns this private workbook. :vartype user_id: str - :param source_id: Optional resourceId for a source resource. - :type source_id: str + :ivar source_id: Optional resourceId for a source resource. + :vartype source_id: str """ _validation = { @@ -1724,6 +2053,36 @@ def __init__( source_id: Optional[str] = None, **kwargs ): + """ + :keyword id: Azure resource Id. + :paramtype id: str + :keyword name: Azure resource name. + :paramtype name: str + :keyword type: Azure resource type. + :paramtype type: str + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind + :keyword display_name: The user-defined name of the private workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular private workbook. Configuration data + is a string containing valid JSON. + :paramtype serialized_data: str + :keyword version: This instance's version of the data model. This can change as new features + are added that can be marked private workbook. + :paramtype version: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: A list of 0 or more tags that are associated with this private + workbook definition. + :paramtype tags_properties_tags: list[str] + :keyword source_id: Optional resourceId for a source resource. + :paramtype source_id: str + """ super(MyWorkbook, self).__init__(id=id, name=name, type=type, location=location, tags=tags, **kwargs) self.kind = kind self.display_name = display_name @@ -1739,13 +2098,13 @@ def __init__( class MyWorkbookError(msrest.serialization.Model): """Error message body that will indicate why the operation failed. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] """ _attribute_map = { @@ -1762,6 +2121,15 @@ def __init__( details: Optional[List["ErrorFieldContract"]] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] + """ super(MyWorkbookError, self).__init__(**kwargs) self.code = code self.message = message @@ -1789,6 +2157,8 @@ def __init__( self, **kwargs ): + """ + """ super(MyWorkbooksListResult, self).__init__(**kwargs) self.value = None @@ -1796,10 +2166,10 @@ def __init__( class Operation(msrest.serialization.Model): """CDN REST API operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.applicationinsights.v2015_05_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.applicationinsights.v2015_05_01.models.OperationDisplay """ _attribute_map = { @@ -1814,6 +2184,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.applicationinsights.v2015_05_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1822,12 +2198,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Cdn. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Cdn. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -1844,6 +2220,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Cdn. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1853,10 +2237,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """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. - :param value: List of CDN operations supported by the CDN resource provider. - :type value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of CDN operations supported by the CDN resource provider. + :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1871,6 +2255,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of CDN operations supported by the CDN resource provider. + :paramtype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1879,10 +2269,10 @@ def __init__( class PrivateLinkScopedResource(msrest.serialization.Model): """The private link scope resource reference. - :param resource_id: The full resource Id of the private link scope resource. - :type resource_id: str - :param scope_id: The private link scope unique Identifier. - :type scope_id: str + :ivar resource_id: The full resource Id of the private link scope resource. + :vartype resource_id: str + :ivar scope_id: The private link scope unique Identifier. + :vartype scope_id: str """ _attribute_map = { @@ -1897,6 +2287,12 @@ def __init__( scope_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: The full resource Id of the private link scope resource. + :paramtype resource_id: str + :keyword scope_id: The private link scope unique Identifier. + :paramtype scope_id: str + """ super(PrivateLinkScopedResource, self).__init__(**kwargs) self.resource_id = resource_id self.scope_id = scope_id @@ -1905,8 +2301,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a WebTest instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1919,6 +2315,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -1936,10 +2336,10 @@ class WebtestsResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1964,6 +2364,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(WebtestsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -1985,36 +2391,36 @@ class WebTest(WebtestsResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of web test that this web test watches. Choices are ping and multistep. + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of web test that this web test watches. Choices are ping and multistep. Possible values include: "ping", "multistep". - :type kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind - :param synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as the + :vartype kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind + :ivar synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as the Name field. - :type synthetic_monitor_id: str - :param web_test_name: User defined name if this WebTest. - :type web_test_name: str - :param description: Purpose/user defined descriptive test for this WebTest. - :type description: str - :param enabled: Is the test actively being monitored. - :type enabled: bool - :param frequency: Interval in seconds between test runs for this WebTest. Default value is 300. - :type frequency: int - :param timeout: Seconds until this WebTest will timeout and fail. Default value is 30. - :type timeout: int - :param web_test_kind: The kind of web test this is, valid choices are ping and multistep. + :vartype synthetic_monitor_id: str + :ivar web_test_name: User defined name if this WebTest. + :vartype web_test_name: str + :ivar description: Purpose/user defined descriptive test for this WebTest. + :vartype description: str + :ivar enabled: Is the test actively being monitored. + :vartype enabled: bool + :ivar frequency: Interval in seconds between test runs for this WebTest. Default value is 300. + :vartype frequency: int + :ivar timeout: Seconds until this WebTest will timeout and fail. Default value is 30. + :vartype timeout: int + :ivar web_test_kind: The kind of web test this is, valid choices are ping and multistep. Possible values include: "ping", "multistep". - :type web_test_kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind - :param retry_enabled: Allow for retries should this WebTest fail. - :type retry_enabled: bool - :param locations: A list of where to physically run the tests from to give global coverage for + :vartype web_test_kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind + :ivar retry_enabled: Allow for retries should this WebTest fail. + :vartype retry_enabled: bool + :ivar locations: A list of where to physically run the tests from to give global coverage for accessibility of your application. - :type locations: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestGeolocation] - :param configuration: An XML configuration specification for a WebTest. - :type configuration: + :vartype locations: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestGeolocation] + :ivar configuration: An XML configuration specification for a WebTest. + :vartype configuration: ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestPropertiesConfiguration :ivar provisioning_state: Current state of this component, whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are @@ -2068,6 +2474,41 @@ def __init__( configuration: Optional["WebTestPropertiesConfiguration"] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of web test that this web test watches. Choices are ping and multistep. + Possible values include: "ping", "multistep". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind + :keyword synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as + the Name field. + :paramtype synthetic_monitor_id: str + :keyword web_test_name: User defined name if this WebTest. + :paramtype web_test_name: str + :keyword description: Purpose/user defined descriptive test for this WebTest. + :paramtype description: str + :keyword enabled: Is the test actively being monitored. + :paramtype enabled: bool + :keyword frequency: Interval in seconds between test runs for this WebTest. Default value is + 300. + :paramtype frequency: int + :keyword timeout: Seconds until this WebTest will timeout and fail. Default value is 30. + :paramtype timeout: int + :keyword web_test_kind: The kind of web test this is, valid choices are ping and multistep. + Possible values include: "ping", "multistep". + :paramtype web_test_kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestKind + :keyword retry_enabled: Allow for retries should this WebTest fail. + :paramtype retry_enabled: bool + :keyword locations: A list of where to physically run the tests from to give global coverage + for accessibility of your application. + :paramtype locations: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestGeolocation] + :keyword configuration: An XML configuration specification for a WebTest. + :paramtype configuration: + ~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestPropertiesConfiguration + """ super(WebTest, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.synthetic_monitor_id = synthetic_monitor_id @@ -2086,8 +2527,8 @@ def __init__( class WebTestGeolocation(msrest.serialization.Model): """Geo-physical location to run a web test from. You must specify one or more locations for the test to run from. - :param location: Location ID for the webtest to run from. - :type location: str + :ivar location: Location ID for the webtest to run from. + :vartype location: str """ _attribute_map = { @@ -2100,6 +2541,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: Location ID for the webtest to run from. + :paramtype location: str + """ super(WebTestGeolocation, self).__init__(**kwargs) self.location = location @@ -2109,11 +2554,11 @@ class WebTestListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. Set of Application Insights web test definitions. - :type value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] - :param next_link: The link to get the next part of the returned list of web tests, should the + :ivar value: Required. Set of Application Insights web test definitions. + :vartype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] + :ivar next_link: The link to get the next part of the returned list of web tests, should the return set be too large for a single request. May be null. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -2132,6 +2577,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. Set of Application Insights web test definitions. + :paramtype value: list[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTest] + :keyword next_link: The link to get the next part of the returned list of web tests, should the + return set be too large for a single request. May be null. + :paramtype next_link: str + """ super(WebTestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2140,8 +2592,8 @@ def __init__( class WebTestPropertiesConfiguration(msrest.serialization.Model): """An XML configuration specification for a WebTest. - :param web_test: The XML specification of a WebTest to run against an application. - :type web_test: str + :ivar web_test: The XML specification of a WebTest to run against an application. + :vartype web_test: str """ _attribute_map = { @@ -2154,6 +2606,10 @@ def __init__( web_test: Optional[str] = None, **kwargs ): + """ + :keyword web_test: The XML specification of a WebTest to run against an application. + :paramtype web_test: str + """ super(WebTestPropertiesConfiguration, self).__init__(**kwargs) self.web_test = web_test @@ -2169,10 +2625,10 @@ class WorkbookResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2196,6 +2652,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(WorkbookResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2215,40 +2677,40 @@ class Workbook(WorkbookResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind - :param name_properties_name: The user-defined name of the workbook. - :type name_properties_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind + :ivar name_properties_name: The user-defined name of the workbook. + :vartype name_properties_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a string containing valid JSON. - :type serialized_data: str - :param version: This instance's version of the data model. This can change as new features are + :vartype serialized_data: str + :ivar version: This instance's version of the data model. This can change as new features are added that can be marked workbook. - :type version: str - :param workbook_id: Internally assigned unique id of the workbook definition. - :type workbook_id: str - :param shared_type_kind: Enum indicating if this workbook definition is owned by a specific - user or is shared between all users with access to the Application Insights component. Possible + :vartype version: str + :ivar workbook_id: Internally assigned unique id of the workbook definition. + :vartype workbook_id: str + :ivar shared_type_kind: Enum indicating if this workbook definition is owned by a specific user + or is shared between all users with access to the Application Insights component. Possible values include: "user", "shared". - :type shared_type_kind: str or + :vartype shared_type_kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind :ivar time_modified: Date and time in UTC of the last modification that was made to this workbook definition. :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: A list of 0 or more tags that are associated with this workbook definition. - :type tags_properties_tags: list[str] - :param user_id: Unique user id of the specific user that owns this workbook. - :type user_id: str - :param source_resource_id: Optional resourceId for a source resource. - :type source_resource_id: str + :vartype tags_properties_tags: list[str] + :ivar user_id: Unique user id of the specific user that owns this workbook. + :vartype user_id: str + :ivar source_resource_id: Optional resourceId for a source resource. + :vartype source_resource_id: str """ _validation = { @@ -2294,6 +2756,39 @@ def __init__( source_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind + :keyword name_properties_name: The user-defined name of the workbook. + :paramtype name_properties_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword version: This instance's version of the data model. This can change as new features + are added that can be marked workbook. + :paramtype version: str + :keyword workbook_id: Internally assigned unique id of the workbook definition. + :paramtype workbook_id: str + :keyword shared_type_kind: Enum indicating if this workbook definition is owned by a specific + user or is shared between all users with access to the Application Insights component. Possible + values include: "user", "shared". + :paramtype shared_type_kind: str or + ~azure.mgmt.applicationinsights.v2015_05_01.models.SharedTypeKind + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: A list of 0 or more tags that are associated with this workbook + definition. + :paramtype tags_properties_tags: list[str] + :keyword user_id: Unique user id of the specific user that owns this workbook. + :paramtype user_id: str + :keyword source_resource_id: Optional resourceId for a source resource. + :paramtype source_resource_id: str + """ super(Workbook, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.name_properties_name = name_properties_name @@ -2311,13 +2806,13 @@ def __init__( class WorkbookError(msrest.serialization.Model): """Error message body that will indicate why the operation failed. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] """ _attribute_map = { @@ -2334,6 +2829,15 @@ def __init__( details: Optional[List["ErrorFieldContract"]] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ErrorFieldContract] + """ super(WorkbookError, self).__init__(**kwargs) self.code = code self.message = message @@ -2361,6 +2865,8 @@ def __init__( self, **kwargs ): + """ + """ super(WorkbooksListResult, self).__init__(**kwargs) self.value = None @@ -2368,16 +2874,16 @@ def __init__( class WorkItemConfiguration(msrest.serialization.Model): """Work item configuration associated with an application insights resource. - :param connector_id: Connector identifier where work item is created. - :type connector_id: str - :param config_display_name: Configuration friendly name. - :type config_display_name: str - :param is_default: Boolean value indicating whether configuration is default. - :type is_default: bool - :param id: Unique Id for work item. - :type id: str - :param config_properties: Serialized JSON object for detailed properties. - :type config_properties: str + :ivar connector_id: Connector identifier where work item is created. + :vartype connector_id: str + :ivar config_display_name: Configuration friendly name. + :vartype config_display_name: str + :ivar is_default: Boolean value indicating whether configuration is default. + :vartype is_default: bool + :ivar id: Unique Id for work item. + :vartype id: str + :ivar config_properties: Serialized JSON object for detailed properties. + :vartype config_properties: str """ _attribute_map = { @@ -2398,6 +2904,18 @@ def __init__( config_properties: Optional[str] = None, **kwargs ): + """ + :keyword connector_id: Connector identifier where work item is created. + :paramtype connector_id: str + :keyword config_display_name: Configuration friendly name. + :paramtype config_display_name: str + :keyword is_default: Boolean value indicating whether configuration is default. + :paramtype is_default: bool + :keyword id: Unique Id for work item. + :paramtype id: str + :keyword config_properties: Serialized JSON object for detailed properties. + :paramtype config_properties: str + """ super(WorkItemConfiguration, self).__init__(**kwargs) self.connector_id = connector_id self.config_display_name = config_display_name @@ -2409,12 +2927,12 @@ def __init__( class WorkItemConfigurationError(msrest.serialization.Model): """Error associated with trying to get work item configuration or configurations. - :param code: Error detail code and explanation. - :type code: str - :param message: Error message. - :type message: str - :param innererror: Inner error. - :type innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError + :ivar code: Error detail code and explanation. + :vartype code: str + :ivar message: Error message. + :vartype message: str + :ivar innererror: Inner error. + :vartype innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError """ _attribute_map = { @@ -2431,6 +2949,14 @@ def __init__( innererror: Optional["InnerError"] = None, **kwargs ): + """ + :keyword code: Error detail code and explanation. + :paramtype code: str + :keyword message: Error message. + :paramtype message: str + :keyword innererror: Inner error. + :paramtype innererror: ~azure.mgmt.applicationinsights.v2015_05_01.models.InnerError + """ super(WorkItemConfigurationError, self).__init__(**kwargs) self.code = code self.message = message @@ -2458,6 +2984,8 @@ def __init__( self, **kwargs ): + """ + """ super(WorkItemConfigurationsListResult, self).__init__(**kwargs) self.value = None @@ -2465,14 +2993,14 @@ def __init__( class WorkItemCreateConfiguration(msrest.serialization.Model): """Work item configuration creation payload. - :param connector_id: Unique connector id. - :type connector_id: str - :param connector_data_configuration: Serialized JSON object for detailed properties. - :type connector_data_configuration: str - :param validate_only: Boolean indicating validate only. - :type validate_only: bool - :param work_item_properties: Custom work item properties. - :type work_item_properties: dict[str, str] + :ivar connector_id: Unique connector id. + :vartype connector_id: str + :ivar connector_data_configuration: Serialized JSON object for detailed properties. + :vartype connector_data_configuration: str + :ivar validate_only: Boolean indicating validate only. + :vartype validate_only: bool + :ivar work_item_properties: Custom work item properties. + :vartype work_item_properties: dict[str, str] """ _attribute_map = { @@ -2491,6 +3019,16 @@ def __init__( work_item_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword connector_id: Unique connector id. + :paramtype connector_id: str + :keyword connector_data_configuration: Serialized JSON object for detailed properties. + :paramtype connector_data_configuration: str + :keyword validate_only: Boolean indicating validate only. + :paramtype validate_only: bool + :keyword work_item_properties: Custom work item properties. + :paramtype work_item_properties: dict[str, str] + """ super(WorkItemCreateConfiguration, self).__init__(**kwargs) self.connector_id = connector_id self.connector_data_configuration = connector_data_configuration diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py index f885efdf5e900..f02d83904f812 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_analytics_items_operations.py @@ -5,22 +5,203 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + *, + scope: Optional[Union[str, "_models.ItemScope"]] = None, + type: Optional[Union[str, "_models.ItemTypeParameter"]] = "none", + include_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scopePath": _SERIALIZER.url("scope_path", scope_path, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if scope is not None: + query_parameters['scope'] = _SERIALIZER.query("scope", scope, 'str') + if type is not None: + query_parameters['type'] = _SERIALIZER.query("type", type, 'str') + if include_content is not None: + query_parameters['includeContent'] = _SERIALIZER.query("include_content", include_content, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + *, + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scopePath": _SERIALIZER.url("scope_path", scope_path, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if id is not None: + query_parameters['id'] = _SERIALIZER.query("id", id, 'str') + if name is not None: + query_parameters['name'] = _SERIALIZER.query("name", name, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + *, + json: JSONType = None, + content: Any = None, + override_item: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scopePath": _SERIALIZER.url("scope_path", scope_path, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if override_item is not None: + query_parameters['overrideItem'] = _SERIALIZER.query("override_item", override_item, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + *, + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scopePath": _SERIALIZER.url("scope_path", scope_path, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if id is not None: + query_parameters['id'] = _SERIALIZER.query("id", id, 'str') + if name is not None: + query_parameters['name'] = _SERIALIZER.query("name", name, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class AnalyticsItemsOperations(object): """AnalyticsItemsOperations operations. @@ -44,17 +225,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - scope_path, # type: Union[str, "_models.ItemScopePath"] - scope=None, # type: Optional[Union[str, "_models.ItemScope"]] - type="none", # type: Optional[Union[str, "_models.ItemTypeParameter"]] - include_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> List["_models.ApplicationInsightsComponentAnalyticsItem"] + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + scope: Optional[Union[str, "_models.ItemScope"]] = None, + type: Optional[Union[str, "_models.ItemTypeParameter"]] = "none", + include_content: Optional[bool] = None, + **kwargs: Any + ) -> List["_models.ApplicationInsightsComponentAnalyticsItem"]: """Gets a list of Analytics Items defined within an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -74,7 +255,8 @@ def list( :type include_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentAnalyticsItem, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem] + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentAnalyticsItem"]] @@ -82,34 +264,21 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if scope is not None: - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - if type is not None: - query_parameters['type'] = self._serialize.query("type", type, 'str') - if include_content is not None: - query_parameters['includeContent'] = self._serialize.query("include_content", include_content, 'bool') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + scope=scope, + type=type, + include_content=include_content, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -123,18 +292,20 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - scope_path, # type: Union[str, "_models.ItemScopePath"] - id=None, # type: Optional[str] - name=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentAnalyticsItem" + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentAnalyticsItem": """Gets a specific Analytics Items defined within an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -150,7 +321,8 @@ def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAnalyticsItem, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAnalyticsItem"] @@ -158,32 +330,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if id is not None: - query_parameters['id'] = self._serialize.query("id", id, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + id=id, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,18 +357,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} # type: ignore + + @distributed_trace def put( self, - resource_group_name, # type: str - resource_name, # type: str - scope_path, # type: Union[str, "_models.ItemScopePath"] - item_properties, # type: "_models.ApplicationInsightsComponentAnalyticsItem" - override_item=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentAnalyticsItem" + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + item_properties: "_models.ApplicationInsightsComponentAnalyticsItem", + override_item: Optional[bool] = None, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentAnalyticsItem": """Adds or Updates a specific Analytics Item within an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -220,13 +382,15 @@ def put( :type scope_path: str or ~azure.mgmt.applicationinsights.v2015_05_01.models.ItemScopePath :param item_properties: Properties that need to be specified to create a new item and add it to an Application Insights component. - :type item_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem + :type item_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :param override_item: Flag indicating whether or not to force save an item. This allows overriding an item if it already exists. :type override_item: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAnalyticsItem, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAnalyticsItem :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAnalyticsItem"] @@ -234,35 +398,24 @@ def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if override_item is not None: - query_parameters['overrideItem'] = self._serialize.query("override_item", override_item, 'bool') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(item_properties, 'ApplicationInsightsComponentAnalyticsItem') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(item_properties, 'ApplicationInsightsComponentAnalyticsItem') + + request = build_put_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + content_type=content_type, + json=_json, + override_item=override_item, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -276,18 +429,20 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized + put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - scope_path, # type: Union[str, "_models.ItemScopePath"] - id=None, # type: Optional[str] - name=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + scope_path: Union[str, "_models.ItemScopePath"], + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> None: """Deletes a specific Analytics Items defined within an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -311,30 +466,20 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scopePath': self._serialize.url("scope_path", scope_path, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if id is not None: - query_parameters['id'] = self._serialize.query("id", id, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + id=id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -346,3 +491,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py index e6d5ed805c33c..d20f9a191ece7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_annotations_operations.py @@ -5,23 +5,178 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + start: str, + end: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['start'] = _SERIALIZER.query("start", start, 'str') + query_parameters['end'] = _SERIALIZER.query("end", end, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + annotation_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "annotationId": _SERIALIZER.url("annotation_id", annotation_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + annotation_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "annotationId": _SERIALIZER.url("annotation_id", annotation_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AnnotationsOperations(object): """AnnotationsOperations operations. @@ -45,15 +200,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - start, # type: str - end, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AnnotationsListResult"] + resource_group_name: str, + resource_name: str, + start: str, + end: str, + **kwargs: Any + ) -> Iterable["_models.AnnotationsListResult"]: """Gets the list of annotations for a component for given time range. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -66,8 +221,10 @@ def list( :param end: The end time to query for annotations. :type end: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AnnotationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.AnnotationsListResult] + :return: An iterator like instance of either AnnotationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.AnnotationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AnnotationsListResult"] @@ -75,38 +232,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['start'] = self._serialize.query("start", start, 'str') - query_parameters['end'] = self._serialize.query("end", end, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + start=start, + end=end, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + start=start, + end=end, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AnnotationsListResult', pipeline_response) + deserialized = self._deserialize("AnnotationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -119,25 +275,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.AnnotationError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations'} # type: ignore + @distributed_trace def create( self, - resource_group_name, # type: str - resource_name, # type: str - annotation_properties, # type: "_models.Annotation" - **kwargs # type: Any - ): - # type: (...) -> List["_models.Annotation"] + resource_group_name: str, + resource_name: str, + annotation_properties: "_models.Annotation", + **kwargs: Any + ) -> List["_models.Annotation"]: """Create an Annotation of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -157,38 +314,28 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(annotation_properties, 'Annotation') + + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(annotation_properties, 'Annotation') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AnnotationError, response) + error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[Annotation]', pipeline_response) @@ -197,16 +344,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - annotation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + annotation_id: str, + **kwargs: Any + ) -> None: """Delete an Annotation of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -226,26 +375,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'annotationId': self._serialize.url("annotation_id", annotation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + annotation_id=annotation_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -258,14 +399,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - annotation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.Annotation"] + resource_group_name: str, + resource_name: str, + annotation_id: str, + **kwargs: Any + ) -> List["_models.Annotation"]: """Get the annotation for given id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -285,34 +427,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'annotationId': self._serialize.url("annotation_id", annotation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + annotation_id=annotation_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AnnotationError, response) + error = self._deserialize.failsafe_deserialize(_models.AnnotationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[Annotation]', pipeline_response) @@ -321,4 +453,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py index 1d6c60b82622c..a08cfee8be785 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_api_keys_operations.py @@ -5,23 +5,179 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + key_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "keyId": _SERIALIZER.url("key_id", key_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + key_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "keyId": _SERIALIZER.url("key_id", key_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class APIKeysOperations(object): """APIKeysOperations operations. @@ -45,13 +201,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsComponentAPIKeyListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsComponentAPIKeyListResult"]: """Gets a list of API keys of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,8 +215,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentAPIKeyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKeyListResult] + :return: An iterator like instance of either ApplicationInsightsComponentAPIKeyListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAPIKeyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAPIKeyListResult"] @@ -68,36 +226,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentAPIKeyListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentAPIKeyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,19 +270,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys'} # type: ignore + @distributed_trace def create( self, - resource_group_name, # type: str - resource_name, # type: str - api_key_properties, # type: "_models.APIKeyRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentAPIKey" + resource_group_name: str, + resource_name: str, + api_key_properties: "_models.APIKeyRequest", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentAPIKey": """Create an API Key of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -147,32 +303,22 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(api_key_properties, 'APIKeyRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(api_key_properties, 'APIKeyRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -186,16 +332,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - key_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentAPIKey" + resource_group_name: str, + resource_name: str, + key_id: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentAPIKey": """Delete an API Key of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -214,28 +362,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyId': self._serialize.url("key_id", key_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + key_id=key_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -249,16 +387,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - key_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentAPIKey" + resource_group_name: str, + resource_name: str, + key_id: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentAPIKey": """Get the API Key for this key id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -277,28 +417,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyId': self._serialize.url("key_id", key_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + key_id=key_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -312,4 +442,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py index 068e9c8fd6041..4f95d9a2ecacf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_available_features_operations.py @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/getavailablebillingfeatures') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ComponentAvailableFeaturesOperations(object): """ComponentAvailableFeaturesOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentAvailableFeatures" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentAvailableFeatures": """Returns all available features of the application insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,7 +96,8 @@ def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentAvailableFeatures, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAvailableFeatures + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentAvailableFeatures :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentAvailableFeatures"] @@ -67,27 +105,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,4 +129,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/getavailablebillingfeatures'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py index 33b17cc0674b2..67d7afc07a93b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_current_billing_features_operations.py @@ -5,22 +5,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ComponentCurrentBillingFeaturesOperations(object): """ComponentCurrentBillingFeaturesOperations operations. @@ -44,13 +126,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentBillingFeatures" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentBillingFeatures": """Returns current billing features for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,7 +141,8 @@ def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentBillingFeatures, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentBillingFeatures"] @@ -67,27 +150,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,16 +174,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - billing_features_properties, # type: "_models.ApplicationInsightsComponentBillingFeatures" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentBillingFeatures" + resource_group_name: str, + resource_name: str, + billing_features_properties: "_models.ApplicationInsightsComponentBillingFeatures", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentBillingFeatures": """Update current billing features for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -119,10 +194,12 @@ def update( :type resource_name: str :param billing_features_properties: Properties that need to be specified to update billing features for an Application Insights component. - :type billing_features_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures + :type billing_features_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentBillingFeatures, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentBillingFeatures :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentBillingFeatures"] @@ -130,32 +207,22 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(billing_features_properties, 'ApplicationInsightsComponentBillingFeatures') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(billing_features_properties, 'ApplicationInsightsComponentBillingFeatures') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,4 +236,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py index 1f06bad635135..7a5ae52ad2d85 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_feature_capabilities_operations.py @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/featurecapabilities') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ComponentFeatureCapabilitiesOperations(object): """ComponentFeatureCapabilitiesOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentFeatureCapabilities" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentFeatureCapabilities": """Returns feature capabilities of the application insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,7 +96,8 @@ def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFeatureCapabilities, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeatureCapabilities + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFeatureCapabilities :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentFeatureCapabilities"] @@ -67,27 +105,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,4 +129,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/featurecapabilities'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py index db9ecbc632460..132c28f365574 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_component_quota_status_operations.py @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ComponentQuotaStatusOperations(object): """ComponentQuotaStatusOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentQuotaStatus" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentQuotaStatus": """Returns daily data volume cap (quota) status for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,7 +96,8 @@ def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentQuotaStatus, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentQuotaStatus + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentQuotaStatus :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentQuotaStatus"] @@ -67,27 +105,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,4 +129,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py index 80c1549bb1c37..90656c1f2f7dc 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_components_operations.py @@ -5,23 +5,323 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_purge_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_purge_status_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + purge_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "purgeId": _SERIALIZER.url("purge_id", purge_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ComponentsOperations(object): """ComponentsOperations operations. @@ -45,16 +345,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsComponentListResult"] + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsComponentListResult"]: """Gets a list of all Application Insights components within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -62,34 +364,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,24 +404,27 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsComponentListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsComponentListResult"]: """Gets a list of Application Insights components within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -132,35 +432,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,18 +474,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Deletes an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -206,25 +503,17 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -237,13 +526,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Returns an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -260,27 +550,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -294,16 +574,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - insight_properties, # type: "_models.ApplicationInsightsComponent" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + insight_properties: "_models.ApplicationInsightsComponent", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Creates (or updates) an Application Insights component. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. @@ -313,7 +595,8 @@ def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. - :type insight_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent + :type insight_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponent @@ -324,32 +607,22 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -363,16 +636,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def update_tags( self, - resource_group_name, # type: str - resource_name, # type: str - component_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + component_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -391,32 +666,22 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(component_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(component_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -430,16 +695,18 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def purge( self, - resource_group_name, # type: str - resource_name, # type: str - body, # type: "_models.ComponentPurgeBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentPurgeResponse" + resource_group_name: str, + resource_name: str, + body: "_models.ComponentPurgeBody", + **kwargs: Any + ) -> "_models.ComponentPurgeResponse": """Purges data in an Application Insights component by a set of user-defined filters. In order to manage system resources, purge requests are throttled at 50 requests per hour. You @@ -465,32 +732,22 @@ def purge( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.purge.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ComponentPurgeBody') + + request = build_purge_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.purge.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ComponentPurgeBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -504,16 +761,18 @@ def purge( return cls(pipeline_response, deserialized, {}) return deserialized + purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'} # type: ignore + + @distributed_trace def get_purge_status( self, - resource_group_name, # type: str - resource_name, # type: str - purge_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentPurgeStatusResponse" + resource_group_name: str, + resource_name: str, + purge_id: str, + **kwargs: Any + ) -> "_models.ComponentPurgeStatusResponse": """Get status for an ongoing purge operation. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -533,28 +792,18 @@ def get_purge_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get_purge_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'purgeId': self._serialize.url("purge_id", purge_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_purge_status_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + purge_id=purge_id, + template_url=self.get_purge_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -568,4 +817,6 @@ def get_purge_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py index 463f6cfaba239..c519bc0f56357 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_export_configurations_operations.py @@ -5,22 +5,224 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + export_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "exportId": _SERIALIZER.url("export_id", export_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + export_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "exportId": _SERIALIZER.url("export_id", export_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + export_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "exportId": _SERIALIZER.url("export_id", export_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ExportConfigurationsOperations(object): """ExportConfigurationsOperations operations. @@ -44,13 +246,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.ApplicationInsightsComponentExportConfiguration"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> List["_models.ApplicationInsightsComponentExportConfiguration"]: """Gets a list of Continuous Export configuration of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -58,8 +260,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] + :return: list of ApplicationInsightsComponentExportConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentExportConfiguration"]] @@ -67,27 +271,17 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,16 +295,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration'} # type: ignore + + @distributed_trace def create( self, - resource_group_name, # type: str - resource_name, # type: str - export_properties, # type: "_models.ApplicationInsightsComponentExportRequest" - **kwargs # type: Any - ): - # type: (...) -> List["_models.ApplicationInsightsComponentExportConfiguration"] + resource_group_name: str, + resource_name: str, + export_properties: "_models.ApplicationInsightsComponentExportRequest", + **kwargs: Any + ) -> List["_models.ApplicationInsightsComponentExportConfiguration"]: """Create a Continuous Export configuration of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -119,10 +315,13 @@ def create( :type resource_name: str :param export_properties: Properties that need to be specified to create a Continuous Export configuration of a Application Insights component. - :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest + :type export_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] + :return: list of ApplicationInsightsComponentExportConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentExportConfiguration"]] @@ -130,32 +329,22 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,16 +358,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - export_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentExportConfiguration" + resource_group_name: str, + resource_name: str, + export_id: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentExportConfiguration": """Delete a Continuous Export configuration of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -190,7 +381,8 @@ def delete( :type export_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentExportConfiguration"] @@ -198,28 +390,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'exportId': self._serialize.url("export_id", export_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + export_id=export_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -233,16 +415,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - export_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentExportConfiguration" + resource_group_name: str, + resource_name: str, + export_id: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentExportConfiguration": """Get the Continuous Export configuration for this export id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -254,7 +438,8 @@ def get( :type export_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentExportConfiguration"] @@ -262,28 +447,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'exportId': self._serialize.url("export_id", export_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + export_id=export_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -297,17 +472,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - export_id, # type: str - export_properties, # type: "_models.ApplicationInsightsComponentExportRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentExportConfiguration" + resource_group_name: str, + resource_name: str, + export_id: str, + export_properties: "_models.ApplicationInsightsComponentExportRequest", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentExportConfiguration": """Update the Continuous Export configuration for this export id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -319,10 +496,12 @@ def update( :type export_id: str :param export_properties: Properties that need to be specified to update the Continuous Export configuration. - :type export_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest + :type export_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentExportConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentExportConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentExportConfiguration"] @@ -330,33 +509,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'exportId': self._serialize.url("export_id", export_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + export_id=export_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_properties, 'ApplicationInsightsComponentExportRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,4 +539,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py index ad99e33a5e51e..9c5f373c309bf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_favorites_operations.py @@ -5,22 +5,233 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + favorite_type: Optional[Union[str, "_models.FavoriteType"]] = None, + source_type: Optional[Union[str, "_models.FavoriteSourceType"]] = None, + can_fetch_content: Optional[bool] = None, + tags: Optional[List[str]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if favorite_type is not None: + query_parameters['favoriteType'] = _SERIALIZER.query("favorite_type", favorite_type, 'str') + if source_type is not None: + query_parameters['sourceType'] = _SERIALIZER.query("source_type", source_type, 'str') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + favorite_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_add_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + favorite_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + favorite_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + favorite_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) class FavoritesOperations(object): """FavoritesOperations operations. @@ -44,17 +255,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - favorite_type=None, # type: Optional[Union[str, "_models.FavoriteType"]] - source_type=None, # type: Optional[Union[str, "_models.FavoriteSourceType"]] - can_fetch_content=None, # type: Optional[bool] - tags=None, # type: Optional[List[str]] - **kwargs # type: Any - ): - # type: (...) -> List["_models.ApplicationInsightsComponentFavorite"] + resource_group_name: str, + resource_name: str, + favorite_type: Optional[Union[str, "_models.FavoriteType"]] = None, + source_type: Optional[Union[str, "_models.FavoriteSourceType"]] = None, + can_fetch_content: Optional[bool] = None, + tags: Optional[List[str]] = None, + **kwargs: Any + ) -> List["_models.ApplicationInsightsComponentFavorite"]: """Gets a list of favorites defined within an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -73,7 +284,8 @@ def list( :type tags: list[str] :keyword callable cls: A custom type or function that will be passed the direct response :return: list of ApplicationInsightsComponentFavorite, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite] + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentFavorite"]] @@ -81,35 +293,21 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if favorite_type is not None: - query_parameters['favoriteType'] = self._serialize.query("favorite_type", favorite_type, 'str') - if source_type is not None: - query_parameters['sourceType'] = self._serialize.query("source_type", source_type, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_type=favorite_type, + source_type=source_type, + can_fetch_content=can_fetch_content, + tags=tags, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -123,16 +321,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - favorite_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentFavorite" + resource_group_name: str, + resource_name: str, + favorite_id: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentFavorite": """Get a single favorite by its FavoriteId, defined within an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -152,28 +352,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,17 +377,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + + @distributed_trace def add( self, - resource_group_name, # type: str - resource_name, # type: str - favorite_id, # type: str - favorite_properties, # type: "_models.ApplicationInsightsComponentFavorite" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentFavorite" + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: "_models.ApplicationInsightsComponentFavorite", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentFavorite": """Adds a new favorites to an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -209,7 +401,8 @@ def add( :type favorite_id: str :param favorite_properties: Properties that need to be specified to create a new favorite and add it to an Application Insights component. - :type favorite_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite + :type favorite_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFavorite, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite @@ -220,33 +413,23 @@ def add( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_add_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + content_type=content_type, + json=_json, + template_url=self.add.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -260,17 +443,19 @@ def add( return cls(pipeline_response, deserialized, {}) return deserialized + add.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - favorite_id, # type: str - favorite_properties, # type: "_models.ApplicationInsightsComponentFavorite" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentFavorite" + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: "_models.ApplicationInsightsComponentFavorite", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentFavorite": """Updates a favorite that has already been added to an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -282,7 +467,8 @@ def update( :type favorite_id: str :param favorite_properties: Properties that need to be specified to update the existing favorite. - :type favorite_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite + :type favorite_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentFavorite, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentFavorite @@ -293,33 +479,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(favorite_properties, 'ApplicationInsightsComponentFavorite') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -333,16 +509,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - favorite_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + favorite_id: str, + **kwargs: Any + ) -> None: """Remove a favorite that is associated to an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -362,26 +540,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'favoriteId': self._serialize.url("favorite_id", favorite_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + favorite_id=favorite_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -393,3 +563,4 @@ def delete( return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py index d61a71d29ae31..c3980aadf50cc 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_my_workbooks_operations.py @@ -5,23 +5,266 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + *, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class MyWorkbooksOperations(object): """MyWorkbooksOperations operations. @@ -45,15 +288,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - category, # type: Union[str, "_models.CategoryType"] - tags=None, # type: Optional[List[str]] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MyWorkbooksListResult"] + resource_group_name: str, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.MyWorkbooksListResult"]: """Get all private workbooks defined within a specified resource group and category. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -66,8 +309,10 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -75,40 +320,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,25 +363,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace def list_by_subscription( self, - category, # type: Union[str, "_models.CategoryType"] - tags=None, # type: Optional[List[str]] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MyWorkbooksListResult"] + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.MyWorkbooksListResult"]: """Get all private workbooks defined within a specified subscription and category. :param category: Category of workbook to return. @@ -150,8 +393,10 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -159,39 +404,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,24 +445,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MyWorkbook" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.MyWorkbook": """Get a single private workbook by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -238,33 +480,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -273,15 +505,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Delete a private workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -298,33 +532,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -332,14 +556,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_properties, # type: "_models.MyWorkbook" - **kwargs # type: Any - ): - # type: (...) -> "_models.MyWorkbook" + resource_group_name: str, + resource_name: str, + workbook_properties: "_models.MyWorkbook", + **kwargs: Any + ) -> "_models.MyWorkbook": """Create a new private workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -359,38 +584,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'MyWorkbook') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -403,16 +618,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_properties, # type: "_models.MyWorkbook" - **kwargs # type: Any - ): - # type: (...) -> "_models.MyWorkbook" + resource_group_name: str, + resource_name: str, + workbook_properties: "_models.MyWorkbook", + **kwargs: Any + ) -> "_models.MyWorkbook": """Updates a private workbook that has already been added. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -432,38 +649,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(workbook_properties, 'MyWorkbook') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -472,4 +679,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py index ed34026606b67..081c442415357 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Insights/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available insights REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py index d30c0b941547b..5a5e628d96e42 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_proactive_detection_configurations_operations.py @@ -5,22 +5,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + configuration_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + configuration_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ProactiveDetectionConfigurationsOperations(object): """ProactiveDetectionConfigurationsOperations operations. @@ -44,13 +165,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"]: """Gets a list of ProactiveDetection configurations of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -58,8 +179,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration] + :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"]] @@ -67,27 +190,17 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,16 +214,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - configuration_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration" + resource_group_name: str, + resource_name: str, + configuration_id: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration": """Get the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -121,8 +236,10 @@ def get( Application Insights component. :type configuration_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -130,28 +247,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,17 +272,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - configuration_id, # type: str - proactive_detection_properties, # type: "_models.ApplicationInsightsComponentProactiveDetectionConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration" + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: "_models.ApplicationInsightsComponentProactiveDetectionConfiguration", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration": """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -187,10 +296,13 @@ def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. - :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -198,33 +310,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -238,4 +340,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py index bac3c23591877..fe61aec1b5656 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_test_locations_operations.py @@ -5,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/syntheticmonitorlocations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WebTestLocationsOperations(object): """WebTestLocationsOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsWebTestLocationsListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsWebTestLocationsListResult"]: """Gets a list of web test locations available to this Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,8 +96,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsWebTestLocationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsWebTestLocationsListResult] + :return: An iterator like instance of either ApplicationInsightsWebTestLocationsListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.ApplicationInsightsWebTestLocationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsWebTestLocationsListResult"] @@ -68,36 +107,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsWebTestLocationsListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsWebTestLocationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,6 +151,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py index f88f73058afa6..c54bde18ada2c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_web_tests_operations.py @@ -5,23 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + web_test_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + subscription_id: str, + web_test_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + web_test_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + web_test_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_component_request( + component_name: str, + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests') + path_format_arguments = { + "componentName": _SERIALIZER.url("component_name", component_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WebTestsOperations(object): """WebTestsOperations operations. @@ -45,19 +299,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebTestListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WebTestListResult"]: """Get all Application Insights web tests defined within a specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -65,35 +320,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,18 +362,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - web_test_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WebTest" + resource_group_name: str, + web_test_name: str, + **kwargs: Any + ) -> "_models.WebTest": """Get a specific Application Insights web test definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -139,27 +391,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,16 +415,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - web_test_name, # type: str - web_test_definition, # type: "_models.WebTest" - **kwargs # type: Any - ): - # type: (...) -> "_models.WebTest" + resource_group_name: str, + web_test_name: str, + web_test_definition: "_models.WebTest", + **kwargs: Any + ) -> "_models.WebTest": """Creates or updates an Application Insights web test definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -202,32 +446,22 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(web_test_definition, 'WebTest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_definition, 'WebTest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -241,16 +475,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def update_tags( self, - resource_group_name, # type: str - web_test_name, # type: str - web_test_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.WebTest" + resource_group_name: str, + web_test_name: str, + web_test_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.WebTest": """Creates or updates an Application Insights web test definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -269,32 +505,22 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(web_test_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,15 +534,17 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - web_test_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + web_test_name: str, + **kwargs: Any + ) -> None: """Deletes an Application Insights web test. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -333,25 +561,17 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + web_test_name=web_test_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -364,16 +584,18 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebTestListResult"] + **kwargs: Any + ) -> Iterable["_models.WebTestListResult"]: """Get all Application Insights web test alerts definitions within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -381,34 +603,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -426,18 +643,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace def list_by_component( self, - component_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebTestListResult"] + component_name: str, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WebTestListResult"]: """Get all Application Insights web tests defined for the specified component. :param component_name: The name of the Application Insights component resource. @@ -446,7 +664,8 @@ def list_by_component( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -454,36 +673,33 @@ def list_by_component( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_component.metadata['url'] # type: ignore - path_format_arguments = { - 'componentName': self._serialize.url("component_name", component_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_component.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -501,6 +717,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py index a79db07583efd..670319f526395 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_work_item_configurations_operations.py @@ -5,23 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_default_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + work_item_config_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_item_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + work_item_config_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_item_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + work_item_config_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class WorkItemConfigurationsOperations(object): """WorkItemConfigurationsOperations operations. @@ -45,13 +276,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkItemConfigurationsListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkItemConfigurationsListResult"]: """Gets the list work item configurations that exist for the application. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,8 +290,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkItemConfigurationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfigurationsListResult] + :return: An iterator like instance of either WorkItemConfigurationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfigurationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkItemConfigurationsListResult"] @@ -68,36 +301,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkItemConfigurationsListResult', pipeline_response) + deserialized = self._deserialize("WorkItemConfigurationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,25 +340,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkItemConfigurationError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkItemConfigurationError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs'} # type: ignore + @distributed_trace def create( self, - resource_group_name, # type: str - resource_name, # type: str - work_item_configuration_properties, # type: "_models.WorkItemCreateConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkItemConfiguration" + resource_group_name: str, + resource_name: str, + work_item_configuration_properties: "_models.WorkItemCreateConfiguration", + **kwargs: Any + ) -> "_models.WorkItemConfiguration": """Create a work item configuration for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -137,7 +368,8 @@ def create( :type resource_name: str :param work_item_configuration_properties: Properties that need to be specified to create a work item configuration of a Application Insights component. - :type work_item_configuration_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration @@ -148,32 +380,22 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') + + request = build_create_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -187,15 +409,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs'} # type: ignore + + @distributed_trace def get_default( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkItemConfiguration" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.WorkItemConfiguration": """Gets default work item configurations that exist for the application. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -212,27 +436,17 @@ def get_default( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get_default.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_default_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get_default.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,16 +460,18 @@ def get_default( return cls(pipeline_response, deserialized, {}) return deserialized + get_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - work_item_config_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + **kwargs: Any + ) -> None: """Delete a work item configuration of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -275,26 +491,18 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'workItemConfigId': self._serialize.url("work_item_config_id", work_item_config_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -307,14 +515,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}'} # type: ignore + + @distributed_trace def get_item( self, - resource_group_name, # type: str - resource_name, # type: str - work_item_config_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkItemConfiguration" + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + **kwargs: Any + ) -> "_models.WorkItemConfiguration": """Gets specified work item configuration for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -334,28 +543,18 @@ def get_item( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get_item.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'workItemConfigId': self._serialize.url("work_item_config_id", work_item_config_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_item_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + template_url=self.get_item.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -369,17 +568,19 @@ def get_item( return cls(pipeline_response, deserialized, {}) return deserialized + get_item.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}'} # type: ignore + + @distributed_trace def update_item( self, - resource_group_name, # type: str - resource_name, # type: str - work_item_config_id, # type: str - work_item_configuration_properties, # type: "_models.WorkItemCreateConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkItemConfiguration" + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + work_item_configuration_properties: "_models.WorkItemCreateConfiguration", + **kwargs: Any + ) -> "_models.WorkItemConfiguration": """Update a work item configuration for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -391,7 +592,8 @@ def update_item( :type work_item_config_id: str :param work_item_configuration_properties: Properties that need to be specified to update a work item configuration for this Application Insights component. - :type work_item_configuration_properties: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemCreateConfiguration :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkItemConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2015_05_01.models.WorkItemConfiguration @@ -402,33 +604,23 @@ def update_item( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_item.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'workItemConfigId': self._serialize.url("work_item_config_id", work_item_config_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') + + request = build_update_item_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + content_type=content_type, + json=_json, + template_url=self.update_item.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(work_item_configuration_properties, 'WorkItemCreateConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,4 +634,6 @@ def update_item( return cls(pipeline_response, deserialized, {}) return deserialized + update_item.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py index a13da447802df..b51588642d0d8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2015_05_01/operations/_workbooks_operations.py @@ -5,23 +5,226 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class WorkbooksOperations(object): """WorkbooksOperations operations. @@ -45,15 +248,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - category, # type: Union[str, "_models.CategoryType"] - tags=None, # type: Optional[List[str]] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkbooksListResult"] + resource_group_name: str, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.WorkbooksListResult"]: """Get all Workbooks defined within a specified resource group and category. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,7 +270,8 @@ def list_by_resource_group( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkbooksListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2015_05_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -75,40 +279,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,24 +322,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.Workbook": """Get a single workbook by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -155,33 +357,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -190,15 +382,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Delete a workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -215,33 +409,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -249,14 +433,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_properties, # type: "_models.Workbook" - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + workbook_properties: "_models.Workbook", + **kwargs: Any + ) -> "_models.Workbook": """Create a new workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -275,38 +460,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(workbook_properties, 'Workbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -319,16 +494,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_properties, # type: "_models.Workbook" - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + workbook_properties: "_models.Workbook", + **kwargs: Any + ) -> "_models.Workbook": """Updates a workbook that has already been added. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -347,38 +524,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'Workbook') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -387,4 +554,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py index 2cae71912a6c6..07fc2e7141f99 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_application_insights_management_client.py @@ -6,88 +6,91 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import ComponentCurrentPricingPlanOperations, EASubscriptionListMigrationDateOperations, EASubscriptionMigrateToNewPricingModelOperations, EASubscriptionRollbackToLegacyPricingModelOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import EASubscriptionMigrateToNewPricingModelOperations -from .operations import EASubscriptionRollbackToLegacyPricingModelOperations -from .operations import EASubscriptionListMigrationDateOperations -from .operations import ComponentCurrentPricingPlanOperations -from . import models - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. - :ivar ea_subscription_migrate_to_new_pricing_model: EASubscriptionMigrateToNewPricingModelOperations operations - :vartype ea_subscription_migrate_to_new_pricing_model: azure.mgmt.applicationinsights.v2017_10_01.operations.EASubscriptionMigrateToNewPricingModelOperations - :ivar ea_subscription_rollback_to_legacy_pricing_model: EASubscriptionRollbackToLegacyPricingModelOperations operations - :vartype ea_subscription_rollback_to_legacy_pricing_model: azure.mgmt.applicationinsights.v2017_10_01.operations.EASubscriptionRollbackToLegacyPricingModelOperations + :ivar ea_subscription_migrate_to_new_pricing_model: + EASubscriptionMigrateToNewPricingModelOperations operations + :vartype ea_subscription_migrate_to_new_pricing_model: + azure.mgmt.applicationinsights.v2017_10_01.operations.EASubscriptionMigrateToNewPricingModelOperations + :ivar ea_subscription_rollback_to_legacy_pricing_model: + EASubscriptionRollbackToLegacyPricingModelOperations operations + :vartype ea_subscription_rollback_to_legacy_pricing_model: + azure.mgmt.applicationinsights.v2017_10_01.operations.EASubscriptionRollbackToLegacyPricingModelOperations :ivar ea_subscription_list_migration_date: EASubscriptionListMigrationDateOperations operations - :vartype ea_subscription_list_migration_date: azure.mgmt.applicationinsights.v2017_10_01.operations.EASubscriptionListMigrationDateOperations + :vartype ea_subscription_list_migration_date: + azure.mgmt.applicationinsights.v2017_10_01.operations.EASubscriptionListMigrationDateOperations :ivar component_current_pricing_plan: ComponentCurrentPricingPlanOperations operations - :vartype component_current_pricing_plan: azure.mgmt.applicationinsights.v2017_10_01.operations.ComponentCurrentPricingPlanOperations + :vartype component_current_pricing_plan: + azure.mgmt.applicationinsights.v2017_10_01.operations.ComponentCurrentPricingPlanOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.ea_subscription_migrate_to_new_pricing_model = EASubscriptionMigrateToNewPricingModelOperations(self._client, self._config, self._serialize, self._deserialize) + self.ea_subscription_rollback_to_legacy_pricing_model = EASubscriptionRollbackToLegacyPricingModelOperations(self._client, self._config, self._serialize, self._deserialize) + self.ea_subscription_list_migration_date = EASubscriptionListMigrationDateOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_current_pricing_plan = ComponentCurrentPricingPlanOperations(self._client, self._config, self._serialize, self._deserialize) - self.ea_subscription_migrate_to_new_pricing_model = EASubscriptionMigrateToNewPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize) - self.ea_subscription_rollback_to_legacy_pricing_model = EASubscriptionRollbackToLegacyPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize) - self.ea_subscription_list_migration_date = EASubscriptionListMigrationDateOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_current_pricing_plan = ComponentCurrentPricingPlanOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py index 2a0a773687c74..33cbc14791ba8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json index 3373a5eaaf0a5..8fd687e97701e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "ea_subscription_migrate_to_new_pricing_model": "EASubscriptionMigrateToNewPricingModelOperations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py index 92f4064007fee..8871c390784a9 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_application_insights_management_client.py @@ -6,84 +6,91 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import ComponentCurrentPricingPlanOperations, EASubscriptionListMigrationDateOperations, EASubscriptionMigrateToNewPricingModelOperations, EASubscriptionRollbackToLegacyPricingModelOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import EASubscriptionMigrateToNewPricingModelOperations -from .operations import EASubscriptionRollbackToLegacyPricingModelOperations -from .operations import EASubscriptionListMigrationDateOperations -from .operations import ComponentCurrentPricingPlanOperations -from .. import models - - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. - :ivar ea_subscription_migrate_to_new_pricing_model: EASubscriptionMigrateToNewPricingModelOperations operations - :vartype ea_subscription_migrate_to_new_pricing_model: azure.mgmt.applicationinsights.v2017_10_01.aio.operations.EASubscriptionMigrateToNewPricingModelOperations - :ivar ea_subscription_rollback_to_legacy_pricing_model: EASubscriptionRollbackToLegacyPricingModelOperations operations - :vartype ea_subscription_rollback_to_legacy_pricing_model: azure.mgmt.applicationinsights.v2017_10_01.aio.operations.EASubscriptionRollbackToLegacyPricingModelOperations + :ivar ea_subscription_migrate_to_new_pricing_model: + EASubscriptionMigrateToNewPricingModelOperations operations + :vartype ea_subscription_migrate_to_new_pricing_model: + azure.mgmt.applicationinsights.v2017_10_01.aio.operations.EASubscriptionMigrateToNewPricingModelOperations + :ivar ea_subscription_rollback_to_legacy_pricing_model: + EASubscriptionRollbackToLegacyPricingModelOperations operations + :vartype ea_subscription_rollback_to_legacy_pricing_model: + azure.mgmt.applicationinsights.v2017_10_01.aio.operations.EASubscriptionRollbackToLegacyPricingModelOperations :ivar ea_subscription_list_migration_date: EASubscriptionListMigrationDateOperations operations - :vartype ea_subscription_list_migration_date: azure.mgmt.applicationinsights.v2017_10_01.aio.operations.EASubscriptionListMigrationDateOperations + :vartype ea_subscription_list_migration_date: + azure.mgmt.applicationinsights.v2017_10_01.aio.operations.EASubscriptionListMigrationDateOperations :ivar component_current_pricing_plan: ComponentCurrentPricingPlanOperations operations - :vartype component_current_pricing_plan: azure.mgmt.applicationinsights.v2017_10_01.aio.operations.ComponentCurrentPricingPlanOperations + :vartype component_current_pricing_plan: + azure.mgmt.applicationinsights.v2017_10_01.aio.operations.ComponentCurrentPricingPlanOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.ea_subscription_migrate_to_new_pricing_model = EASubscriptionMigrateToNewPricingModelOperations(self._client, self._config, self._serialize, self._deserialize) + self.ea_subscription_rollback_to_legacy_pricing_model = EASubscriptionRollbackToLegacyPricingModelOperations(self._client, self._config, self._serialize, self._deserialize) + self.ea_subscription_list_migration_date = EASubscriptionListMigrationDateOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_current_pricing_plan = ComponentCurrentPricingPlanOperations(self._client, self._config, self._serialize, self._deserialize) - self.ea_subscription_migrate_to_new_pricing_model = EASubscriptionMigrateToNewPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize) - self.ea_subscription_rollback_to_legacy_pricing_model = EASubscriptionRollbackToLegacyPricingModelOperations( - self._client, self._config, self._serialize, self._deserialize) - self.ea_subscription_list_migration_date = EASubscriptionListMigrationDateOperations( - self._client, self._config, self._serialize, self._deserialize) - self.component_current_pricing_plan = ComponentCurrentPricingPlanOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py index 6e105e28c8b0e..847afaed80391 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py index fbbd9494a0d66..0ee445da3483f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_component_current_pricing_plan_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._component_current_pricing_plan_operations import build_create_and_update_request, build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -54,7 +59,8 @@ async def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :rtype: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentPricingPlan"] @@ -62,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +92,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current'} # type: ignore + + @distributed_trace_async async def create_and_update( self, resource_group_name: str, @@ -113,10 +112,12 @@ async def create_and_update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. - :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :type pricing_plan_properties: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :rtype: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentPricingPlan"] @@ -124,32 +125,22 @@ async def create_and_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_and_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_and_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_and_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,8 +154,11 @@ async def create_and_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_and_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -180,10 +174,12 @@ async def update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. - :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :type pricing_plan_properties: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :rtype: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentPricingPlan"] @@ -191,32 +187,22 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -230,4 +216,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py index 3d53810148919..e93856b6a75cd 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_list_migration_date_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._ea_subscription_list_migration_date_operations import build_post_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def post( self, **kwargs: Any @@ -56,25 +61,15 @@ async def post( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.post.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_post_request( + subscription_id=self._config.subscription_id, + template_url=self.post.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -88,4 +83,6 @@ async def post( return cls(pipeline_response, deserialized, {}) return deserialized + post.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/listMigrationdate'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py index d2fa1313d8a3d..bfe623a1c9a9b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._ea_subscription_migrate_to_new_pricing_model_operations import build_post_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def post( self, **kwargs: Any @@ -56,25 +61,15 @@ async def post( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.post.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_post_request( + subscription_id=self._config.subscription_id, + template_url=self.post.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,3 +81,4 @@ async def post( return cls(pipeline_response, None, {}) post.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/migrateToNewPricingModel'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py index a73be76e67c9a..e8d32c6e8fb4a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/aio/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._ea_subscription_rollback_to_legacy_pricing_model_operations import build_post_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def post( self, **kwargs: Any @@ -56,25 +61,15 @@ async def post( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.post.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_post_request( + subscription_id=self._config.subscription_id, + template_url=self.post.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,3 +81,4 @@ async def post( return cls(pipeline_response, None, {}) post.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/rollbackToLegacyPricingModel'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py index 5bc25d104c436..d989630558f4a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/__init__.py @@ -6,16 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApplicationInsightsComponentPricingPlan - from ._models_py3 import CloudErrorBody - from ._models_py3 import EASubscriptionMigrationDate - from ._models_py3 import Resource -except (SyntaxError, ImportError): - from ._models import ApplicationInsightsComponentPricingPlan # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import EASubscriptionMigrationDate # type: ignore - from ._models import Resource # type: ignore +from ._models_py3 import ApplicationInsightsComponentPricingPlan +from ._models_py3 import CloudErrorBody +from ._models_py3 import EASubscriptionMigrationDate +from ._models_py3 import Resource + __all__ = [ 'ApplicationInsightsComponentPricingPlan', diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models.py deleted file mode 100644 index a0425e0ae3373..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models.py +++ /dev/null @@ -1,165 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """An Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ApplicationInsightsComponentPricingPlan(Resource): - """An Application Insights component pricing plan. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param plan_type: Pricing Plan Type Name. - :type plan_type: str - :param cap: Daily data volume cap in GB. - :type cap: float - :ivar reset_hour: Daily data volume cap UTC reset hour. - :vartype reset_hour: int - :param warning_threshold: Reserved, not used for now. - :type warning_threshold: int - :param stop_send_notification_when_hit_threshold: Reserved, not used for now. - :type stop_send_notification_when_hit_threshold: bool - :param stop_send_notification_when_hit_cap: Do not send a notification email when the daily - data volume cap is met. - :type stop_send_notification_when_hit_cap: bool - :ivar max_history_cap: Maximum daily data volume cap that the user can set for this component. - :vartype max_history_cap: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'reset_hour': {'readonly': True}, - 'max_history_cap': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'plan_type': {'key': 'properties.planType', 'type': 'str'}, - 'cap': {'key': 'properties.cap', 'type': 'float'}, - 'reset_hour': {'key': 'properties.resetHour', 'type': 'int'}, - 'warning_threshold': {'key': 'properties.warningThreshold', 'type': 'int'}, - 'stop_send_notification_when_hit_threshold': {'key': 'properties.stopSendNotificationWhenHitThreshold', 'type': 'bool'}, - 'stop_send_notification_when_hit_cap': {'key': 'properties.stopSendNotificationWhenHitCap', 'type': 'bool'}, - 'max_history_cap': {'key': 'properties.maxHistoryCap', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentPricingPlan, self).__init__(**kwargs) - self.plan_type = kwargs.get('plan_type', None) - self.cap = kwargs.get('cap', None) - self.reset_hour = None - self.warning_threshold = kwargs.get('warning_threshold', None) - self.stop_send_notification_when_hit_threshold = kwargs.get('stop_send_notification_when_hit_threshold', None) - self.stop_send_notification_when_hit_cap = kwargs.get('stop_send_notification_when_hit_cap', None) - self.max_history_cap = None - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the Batch service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in - error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.applicationinsights.v2017_10_01.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class EASubscriptionMigrationDate(msrest.serialization.Model): - """Subscription migrate date information properties. - - :param is_grand_fatherable_subscription: Is subscription in the grand fatherable subscription - list. - :type is_grand_fatherable_subscription: bool - :param opted_in_date: Time to start using new pricing model. - :type opted_in_date: ~datetime.datetime - """ - - _attribute_map = { - 'is_grand_fatherable_subscription': {'key': 'isGrandFatherableSubscription', 'type': 'bool'}, - 'opted_in_date': {'key': 'optedInDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(EASubscriptionMigrationDate, self).__init__(**kwargs) - self.is_grand_fatherable_subscription = kwargs.get('is_grand_fatherable_subscription', None) - self.opted_in_date = kwargs.get('opted_in_date', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py index 26472fb64a7fa..4d58570876d63 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/models/_models_py3.py @@ -41,6 +41,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -58,19 +60,19 @@ class ApplicationInsightsComponentPricingPlan(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param plan_type: Pricing Plan Type Name. - :type plan_type: str - :param cap: Daily data volume cap in GB. - :type cap: float + :ivar plan_type: Pricing Plan Type Name. + :vartype plan_type: str + :ivar cap: Daily data volume cap in GB. + :vartype cap: float :ivar reset_hour: Daily data volume cap UTC reset hour. :vartype reset_hour: int - :param warning_threshold: Reserved, not used for now. - :type warning_threshold: int - :param stop_send_notification_when_hit_threshold: Reserved, not used for now. - :type stop_send_notification_when_hit_threshold: bool - :param stop_send_notification_when_hit_cap: Do not send a notification email when the daily - data volume cap is met. - :type stop_send_notification_when_hit_cap: bool + :ivar warning_threshold: Reserved, not used for now. + :vartype warning_threshold: int + :ivar stop_send_notification_when_hit_threshold: Reserved, not used for now. + :vartype stop_send_notification_when_hit_threshold: bool + :ivar stop_send_notification_when_hit_cap: Do not send a notification email when the daily data + volume cap is met. + :vartype stop_send_notification_when_hit_cap: bool :ivar max_history_cap: Maximum daily data volume cap that the user can set for this component. :vartype max_history_cap: float """ @@ -106,6 +108,19 @@ def __init__( stop_send_notification_when_hit_cap: Optional[bool] = None, **kwargs ): + """ + :keyword plan_type: Pricing Plan Type Name. + :paramtype plan_type: str + :keyword cap: Daily data volume cap in GB. + :paramtype cap: float + :keyword warning_threshold: Reserved, not used for now. + :paramtype warning_threshold: int + :keyword stop_send_notification_when_hit_threshold: Reserved, not used for now. + :paramtype stop_send_notification_when_hit_threshold: bool + :keyword stop_send_notification_when_hit_cap: Do not send a notification email when the daily + data volume cap is met. + :paramtype stop_send_notification_when_hit_cap: bool + """ super(ApplicationInsightsComponentPricingPlan, self).__init__(**kwargs) self.plan_type = plan_type self.cap = cap @@ -119,17 +134,17 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """An error response from the Batch service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.applicationinsights.v2017_10_01.models.CloudErrorBody] + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.applicationinsights.v2017_10_01.models.CloudErrorBody] """ _attribute_map = { @@ -148,6 +163,19 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.applicationinsights.v2017_10_01.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -158,11 +186,11 @@ def __init__( class EASubscriptionMigrationDate(msrest.serialization.Model): """Subscription migrate date information properties. - :param is_grand_fatherable_subscription: Is subscription in the grand fatherable subscription + :ivar is_grand_fatherable_subscription: Is subscription in the grand fatherable subscription list. - :type is_grand_fatherable_subscription: bool - :param opted_in_date: Time to start using new pricing model. - :type opted_in_date: ~datetime.datetime + :vartype is_grand_fatherable_subscription: bool + :ivar opted_in_date: Time to start using new pricing model. + :vartype opted_in_date: ~datetime.datetime """ _attribute_map = { @@ -177,6 +205,13 @@ def __init__( opted_in_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword is_grand_fatherable_subscription: Is subscription in the grand fatherable subscription + list. + :paramtype is_grand_fatherable_subscription: bool + :keyword opted_in_date: Time to start using new pricing model. + :paramtype opted_in_date: ~datetime.datetime + """ super(EASubscriptionMigrationDate, self).__init__(**kwargs) self.is_grand_fatherable_subscription = is_grand_fatherable_subscription self.opted_in_date = opted_in_date diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py index 2b6c4f078d85d..540b37f4ad89b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_component_current_pricing_plan_operations.py @@ -5,22 +5,148 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_and_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ComponentCurrentPricingPlanOperations(object): """ComponentCurrentPricingPlanOperations operations. @@ -44,13 +170,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentPricingPlan" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentPricingPlan": """Returns the current pricing plan setting for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -59,7 +185,8 @@ def get( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :rtype: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentPricingPlan"] @@ -67,27 +194,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,16 +218,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current'} # type: ignore + + @distributed_trace def create_and_update( self, - resource_group_name, # type: str - resource_name, # type: str - pricing_plan_properties, # type: "_models.ApplicationInsightsComponentPricingPlan" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentPricingPlan" + resource_group_name: str, + resource_name: str, + pricing_plan_properties: "_models.ApplicationInsightsComponentPricingPlan", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentPricingPlan": """Replace current pricing plan for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -119,10 +238,12 @@ def create_and_update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. - :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :type pricing_plan_properties: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :rtype: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentPricingPlan"] @@ -130,32 +251,22 @@ def create_and_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_and_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') + + request = build_create_and_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_and_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,16 +280,18 @@ def create_and_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_and_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - pricing_plan_properties, # type: "_models.ApplicationInsightsComponentPricingPlan" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentPricingPlan" + resource_group_name: str, + resource_name: str, + pricing_plan_properties: "_models.ApplicationInsightsComponentPricingPlan", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentPricingPlan": """Update current pricing plan for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -187,10 +300,12 @@ def update( :type resource_name: str :param pricing_plan_properties: Properties that need to be specified to update current pricing plan for an Application Insights component. - :type pricing_plan_properties: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :type pricing_plan_properties: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponentPricingPlan, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan + :rtype: + ~azure.mgmt.applicationinsights.v2017_10_01.models.ApplicationInsightsComponentPricingPlan :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentPricingPlan"] @@ -198,32 +313,22 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(pricing_plan_properties, 'ApplicationInsightsComponentPricingPlan') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -237,4 +342,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/pricingPlans/current'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py index dea0c4f19e5d6..a3ca7e45dff89 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_list_migration_date_operations.py @@ -5,22 +5,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_post_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/listMigrationdate') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class EASubscriptionListMigrationDateOperations(object): """EASubscriptionListMigrationDateOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def post( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.EASubscriptionMigrationDate" + **kwargs: Any + ) -> "_models.EASubscriptionMigrationDate": """list date to migrate to new pricing model. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,25 +94,15 @@ def post( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.post.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_post_request( + subscription_id=self._config.subscription_id, + template_url=self.post.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,4 +116,6 @@ def post( return cls(pipeline_response, deserialized, {}) return deserialized + post.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/listMigrationdate'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py index 9c6bef880d3bd..fe7b6aebc32a3 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_migrate_to_new_pricing_model_operations.py @@ -5,22 +5,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_post_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/migrateToNewPricingModel') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class EASubscriptionMigrateToNewPricingModelOperations(object): """EASubscriptionMigrateToNewPricingModelOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def post( self, - **kwargs # type: Any - ): - # type: (...) -> None + **kwargs: Any + ) -> None: """Enterprise Agreement Customer opted to use new pricing model. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,25 +94,15 @@ def post( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.post.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_post_request( + subscription_id=self._config.subscription_id, + template_url=self.post.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,3 +114,4 @@ def post( return cls(pipeline_response, None, {}) post.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/migrateToNewPricingModel'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py index ace58f99250ee..901d86bcfd034 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2017_10_01/operations/_ea_subscription_rollback_to_legacy_pricing_model_operations.py @@ -5,22 +5,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_post_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/rollbackToLegacyPricingModel') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class EASubscriptionRollbackToLegacyPricingModelOperations(object): """EASubscriptionRollbackToLegacyPricingModelOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def post( self, - **kwargs # type: Any - ): - # type: (...) -> None + **kwargs: Any + ) -> None: """Enterprise Agreement Customer roll back to use legacy pricing model. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,25 +94,15 @@ def post( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-10-01" - accept = "application/json" - - # Construct URL - url = self.post.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_post_request( + subscription_id=self._config.subscription_id, + template_url=self.post.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,3 +114,4 @@ def post( return cls(pipeline_response, None, {}) post.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/rollbackToLegacyPricingModel'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py index 123e7bc174bf3..e944d3de983e4 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_application_insights_management_client.py @@ -6,88 +6,88 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import ComponentsOperations, Operations, ProactiveDetectionConfigurationsOperations, WebTestsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import ProactiveDetectionConfigurationsOperations -from .operations import ComponentsOperations -from .operations import Operations -from .operations import WebTestsOperations -from . import models - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations - :vartype proactive_detection_configurations: azure.mgmt.applicationinsights.v2018_05_01_preview.operations.ProactiveDetectionConfigurationsOperations + :vartype proactive_detection_configurations: + azure.mgmt.applicationinsights.v2018_05_01_preview.operations.ProactiveDetectionConfigurationsOperations :ivar components: ComponentsOperations operations - :vartype components: azure.mgmt.applicationinsights.v2018_05_01_preview.operations.ComponentsOperations + :vartype components: + azure.mgmt.applicationinsights.v2018_05_01_preview.operations.ComponentsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.applicationinsights.v2018_05_01_preview.operations.Operations :ivar web_tests: WebTestsOperations operations - :vartype web_tests: azure.mgmt.applicationinsights.v2018_05_01_preview.operations.WebTestsOperations + :vartype web_tests: + azure.mgmt.applicationinsights.v2018_05_01_preview.operations.WebTestsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.components = ComponentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.web_tests = WebTestsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py index f31b533103f7c..034fa34e8df3d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json index d8f8643241820..dc1b8afe28d72 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "proactive_detection_configurations": "ProactiveDetectionConfigurationsOperations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py index e8418a68b60ae..03adb1a16d652 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_application_insights_management_client.py @@ -6,84 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import ComponentsOperations, Operations, ProactiveDetectionConfigurationsOperations, WebTestsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import ProactiveDetectionConfigurationsOperations -from .operations import ComponentsOperations -from .operations import Operations -from .operations import WebTestsOperations -from .. import models - - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations - :vartype proactive_detection_configurations: azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.ProactiveDetectionConfigurationsOperations + :vartype proactive_detection_configurations: + azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.ProactiveDetectionConfigurationsOperations :ivar components: ComponentsOperations operations - :vartype components: azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.ComponentsOperations + :vartype components: + azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.ComponentsOperations :ivar operations: Operations operations - :vartype operations: azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.Operations + :vartype operations: + azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.Operations :ivar web_tests: WebTestsOperations operations - :vartype web_tests: azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.WebTestsOperations + :vartype web_tests: + azure.mgmt.applicationinsights.v2018_05_01_preview.aio.operations.WebTestsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.components = ComponentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.web_tests = WebTestsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py index e2cd4f172e4cb..19ebfe11aa504 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py index cd8e631052c44..067f0edcac18d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_components_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._components_operations import build_create_or_update_request, build_delete_request, build_get_purge_status_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_purge_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """Gets a list of all Application Insights components within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,11 +105,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -117,8 +122,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -126,35 +133,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,11 +175,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -199,25 +204,17 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -230,6 +227,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -252,27 +251,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -286,8 +275,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -304,7 +296,8 @@ async def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. - :type insight_properties: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent + :type insight_properties: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent @@ -315,32 +308,22 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -358,8 +341,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, @@ -385,32 +371,22 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(component_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(component_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -428,8 +404,11 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def purge( self, resource_group_name: str, @@ -462,32 +441,22 @@ async def purge( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.purge.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ComponentPurgeBody') + + request = build_purge_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.purge.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ComponentPurgeBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -501,8 +470,11 @@ async def purge( return cls(pipeline_response, deserialized, {}) return deserialized + purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'} # type: ignore + + @distributed_trace_async async def get_purge_status( self, resource_group_name: str, @@ -529,28 +501,18 @@ async def get_purge_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_purge_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'purgeId': self._serialize.url("purge_id", purge_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_purge_status_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + purge_id=purge_id, + template_url=self.get_purge_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -564,4 +526,6 @@ async def get_purge_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py index c792244dd018d..07f3af348e9db 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -50,8 +56,10 @@ def list( List the available operations supported by the Microsoft.EventGrid resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationsListResult] + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] @@ -59,30 +67,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,6 +105,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py index e212cbcdf99fd..1d2829dca1074 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_proactive_detection_configurations_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._proactive_detection_configurations_operations import build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -53,8 +58,10 @@ async def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration] + :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"]] @@ -62,27 +69,17 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +93,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -115,8 +115,10 @@ async def get( Application Insights component. :type configuration_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -124,28 +126,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,8 +151,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -180,10 +175,13 @@ async def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. - :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -191,33 +189,23 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -231,4 +219,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py index 6c23175ff24cc..98e92731d9f34 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/aio/operations/_web_tests_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._web_tests_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_component_request, build_list_by_resource_group_request, build_list_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -52,7 +58,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -60,35 +67,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,11 +109,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -133,27 +138,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -167,8 +162,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -195,32 +193,22 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(web_test_definition, 'WebTest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_definition, 'WebTest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,8 +222,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, @@ -261,32 +252,22 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(web_test_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -300,8 +281,11 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -324,25 +308,17 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + web_test_name=web_test_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -355,6 +331,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -363,7 +341,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -371,34 +350,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -416,11 +390,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace def list_by_component( self, component_name: str, @@ -435,7 +411,8 @@ def list_by_component( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -443,36 +420,33 @@ def list_by_component( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_component.metadata['url'] # type: ignore - path_format_arguments = { - 'componentName': self._serialize.url("component_name", component_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_component.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -490,6 +464,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py index 184713ecd48fd..899b479670b33 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/__init__.py @@ -6,54 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApplicationInsightsComponent - from ._models_py3 import ApplicationInsightsComponentListResult - from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfiguration - from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions - from ._models_py3 import ComponentPurgeBody - from ._models_py3 import ComponentPurgeBodyFilters - from ._models_py3 import ComponentPurgeResponse - from ._models_py3 import ComponentPurgeStatusResponse - from ._models_py3 import ComponentsResource - from ._models_py3 import HeaderField - from ._models_py3 import Operation - from ._models_py3 import OperationInfo - from ._models_py3 import OperationsListResult - from ._models_py3 import PrivateLinkScopedResource - from ._models_py3 import TagsResource - from ._models_py3 import WebTest - from ._models_py3 import WebTestGeolocation - from ._models_py3 import WebTestListResult - from ._models_py3 import WebTestPropertiesConfiguration - from ._models_py3 import WebTestPropertiesRequest - from ._models_py3 import WebTestPropertiesValidationRules - from ._models_py3 import WebTestPropertiesValidationRulesContentValidation - from ._models_py3 import WebtestsResource -except (SyntaxError, ImportError): - from ._models import ApplicationInsightsComponent # type: ignore - from ._models import ApplicationInsightsComponentListResult # type: ignore - from ._models import ApplicationInsightsComponentProactiveDetectionConfiguration # type: ignore - from ._models import ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions # type: ignore - from ._models import ComponentPurgeBody # type: ignore - from ._models import ComponentPurgeBodyFilters # type: ignore - from ._models import ComponentPurgeResponse # type: ignore - from ._models import ComponentPurgeStatusResponse # type: ignore - from ._models import ComponentsResource # type: ignore - from ._models import HeaderField # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationInfo # type: ignore - from ._models import OperationsListResult # type: ignore - from ._models import PrivateLinkScopedResource # type: ignore - from ._models import TagsResource # type: ignore - from ._models import WebTest # type: ignore - from ._models import WebTestGeolocation # type: ignore - from ._models import WebTestListResult # type: ignore - from ._models import WebTestPropertiesConfiguration # type: ignore - from ._models import WebTestPropertiesRequest # type: ignore - from ._models import WebTestPropertiesValidationRules # type: ignore - from ._models import WebTestPropertiesValidationRulesContentValidation # type: ignore - from ._models import WebtestsResource # type: ignore +from ._models_py3 import ApplicationInsightsComponent +from ._models_py3 import ApplicationInsightsComponentListResult +from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfiguration +from ._models_py3 import ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions +from ._models_py3 import ComponentPurgeBody +from ._models_py3 import ComponentPurgeBodyFilters +from ._models_py3 import ComponentPurgeResponse +from ._models_py3 import ComponentPurgeStatusResponse +from ._models_py3 import ComponentsResource +from ._models_py3 import HeaderField +from ._models_py3 import Operation +from ._models_py3 import OperationInfo +from ._models_py3 import OperationsListResult +from ._models_py3 import PrivateLinkScopedResource +from ._models_py3 import TagsResource +from ._models_py3 import WebTest +from ._models_py3 import WebTestGeolocation +from ._models_py3 import WebTestListResult +from ._models_py3 import WebTestPropertiesConfiguration +from ._models_py3 import WebTestPropertiesRequest +from ._models_py3 import WebTestPropertiesValidationRules +from ._models_py3 import WebTestPropertiesValidationRulesContentValidation +from ._models_py3 import WebtestsResource + from ._application_insights_management_client_enums import ( ApplicationType, diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_application_insights_management_client_enums.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_application_insights_management_client_enums.py index a71373b140fc5..a4cfb26c4dcfa 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_application_insights_management_client_enums.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_application_insights_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ApplicationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApplicationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of application being monitored. """ WEB = "web" OTHER = "other" -class FlowType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FlowType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. @@ -41,7 +26,7 @@ class FlowType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BLUEFIELD = "Bluefield" -class IngestionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IngestionMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the flow of the ingestion. """ @@ -49,7 +34,7 @@ class IngestionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPLICATION_INSIGHTS_WITH_DIAGNOSTIC_SETTINGS = "ApplicationInsightsWithDiagnosticSettings" LOG_ANALYTICS = "LogAnalytics" -class PublicNetworkAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The network access type for operating on the Application Insights Component. By default it is Enabled """ @@ -59,28 +44,28 @@ class PublicNetworkAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum #: Disables public connectivity to Application Insights through public DNS. DISABLED = "Disabled" -class PurgeState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PurgeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the operation represented by the requested Id. """ PENDING = "pending" COMPLETED = "completed" -class RequestSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RequestSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. """ REST = "rest" -class WebTestKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WebTestKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of WebTest that this web test watches. Choices are ping and multistep. """ PING = "ping" MULTISTEP = "multistep" -class WebTestKindEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WebTestKindEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of web test this is, valid choices are ping, multistep, basic, and standard. """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models.py deleted file mode 100644 index 3e55141ec828b..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models.py +++ /dev/null @@ -1,961 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class ComponentsResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentsResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ApplicationInsightsComponent(ComponentsResource): - """An Application Insights component definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. The kind of application that this component refers to, used to customize - UI. This value is a freeform string, values should typically be one of the following: web, ios, - other, store, java, phone. - :type kind: str - :ivar application_id: The unique ID of your application. This field mirrors the 'Name' field - and cannot be changed. - :vartype application_id: str - :ivar app_id: Application Insights Unique ID for your Application. - :vartype app_id: str - :param application_type: Type of application being monitored. Possible values include: "web", - "other". Default value: "web". - :type application_type: str or - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationType - :param flow_type: Used by the Application Insights system to determine what kind of flow this - component was created by. This is to be set to 'Bluefield' when creating/updating a component - via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". - :type flow_type: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.FlowType - :param request_source: Describes what tool created this Application Insights component. - Customers using this API should set this to the default 'rest'. Possible values include: - "rest". Default value: "rest". - :type request_source: str or - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.RequestSource - :ivar instrumentation_key: Application Insights Instrumentation key. A read-only value that - applications can use to identify the destination for all telemetry sent to Azure Application - Insights. This value will be supplied upon construction of each new Application Insights - component. - :vartype instrumentation_key: str - :ivar creation_date: Creation Date for the Application Insights component, in ISO 8601 format. - :vartype creation_date: ~datetime.datetime - :ivar tenant_id: Azure Tenant Id. - :vartype tenant_id: str - :param hockey_app_id: The unique application ID created when a new application is added to - HockeyApp, used for communications with HockeyApp. - :type hockey_app_id: str - :ivar hockey_app_token: Token used to authenticate communications with between Application - Insights and HockeyApp. - :vartype hockey_app_token: str - :ivar provisioning_state: Current state of this component: whether or not is has been - provisioned within the resource group it is defined. Users cannot change this value but are - able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. - :vartype provisioning_state: str - :param sampling_percentage: Percentage of the data produced by the application being monitored - that is being sampled for Application Insights telemetry. - :type sampling_percentage: float - :ivar connection_string: Application Insights component connection string. - :vartype connection_string: str - :param retention_in_days: Retention period in days. - :type retention_in_days: int - :param disable_ip_masking: Disable IP masking. - :type disable_ip_masking: bool - :param immediate_purge_data_on30_days: Purge data immediately after 30 days. - :type immediate_purge_data_on30_days: bool - :ivar private_link_scoped_resources: List of linked private link scope resources. - :vartype private_link_scoped_resources: - list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PrivateLinkScopedResource] - :param public_network_access_for_ingestion: The network access type for accessing Application - Insights ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_ingestion: str or - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PublicNetworkAccessType - :param public_network_access_for_query: The network access type for accessing Application - Insights query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_query: str or - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PublicNetworkAccessType - :param ingestion_mode: Indicates the flow of the ingestion. Possible values include: - "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default - value: "ApplicationInsights". - :type ingestion_mode: str or - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.IngestionMode - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'application_id': {'readonly': True}, - 'app_id': {'readonly': True}, - 'instrumentation_key': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'hockey_app_token': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'connection_string': {'readonly': True}, - 'private_link_scoped_resources': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'application_id': {'key': 'properties.ApplicationId', 'type': 'str'}, - 'app_id': {'key': 'properties.AppId', 'type': 'str'}, - 'application_type': {'key': 'properties.Application_Type', 'type': 'str'}, - 'flow_type': {'key': 'properties.Flow_Type', 'type': 'str'}, - 'request_source': {'key': 'properties.Request_Source', 'type': 'str'}, - 'instrumentation_key': {'key': 'properties.InstrumentationKey', 'type': 'str'}, - 'creation_date': {'key': 'properties.CreationDate', 'type': 'iso-8601'}, - 'tenant_id': {'key': 'properties.TenantId', 'type': 'str'}, - 'hockey_app_id': {'key': 'properties.HockeyAppId', 'type': 'str'}, - 'hockey_app_token': {'key': 'properties.HockeyAppToken', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sampling_percentage': {'key': 'properties.SamplingPercentage', 'type': 'float'}, - 'connection_string': {'key': 'properties.ConnectionString', 'type': 'str'}, - 'retention_in_days': {'key': 'properties.RetentionInDays', 'type': 'int'}, - 'disable_ip_masking': {'key': 'properties.DisableIpMasking', 'type': 'bool'}, - 'immediate_purge_data_on30_days': {'key': 'properties.ImmediatePurgeDataOn30Days', 'type': 'bool'}, - 'private_link_scoped_resources': {'key': 'properties.PrivateLinkScopedResources', 'type': '[PrivateLinkScopedResource]'}, - 'public_network_access_for_ingestion': {'key': 'properties.publicNetworkAccessForIngestion', 'type': 'str'}, - 'public_network_access_for_query': {'key': 'properties.publicNetworkAccessForQuery', 'type': 'str'}, - 'ingestion_mode': {'key': 'properties.IngestionMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponent, self).__init__(**kwargs) - self.kind = kwargs['kind'] - self.application_id = None - self.app_id = None - self.application_type = kwargs.get('application_type', "web") - self.flow_type = kwargs.get('flow_type', "Bluefield") - self.request_source = kwargs.get('request_source', "rest") - self.instrumentation_key = None - self.creation_date = None - self.tenant_id = None - self.hockey_app_id = kwargs.get('hockey_app_id', None) - self.hockey_app_token = None - self.provisioning_state = None - self.sampling_percentage = kwargs.get('sampling_percentage', None) - self.connection_string = None - self.retention_in_days = kwargs.get('retention_in_days', 90) - self.disable_ip_masking = kwargs.get('disable_ip_masking', None) - self.immediate_purge_data_on30_days = kwargs.get('immediate_purge_data_on30_days', None) - self.private_link_scoped_resources = None - self.public_network_access_for_ingestion = kwargs.get('public_network_access_for_ingestion', "Enabled") - self.public_network_access_for_query = kwargs.get('public_network_access_for_query', "Enabled") - self.ingestion_mode = kwargs.get('ingestion_mode', "ApplicationInsights") - - -class ApplicationInsightsComponentListResult(msrest.serialization.Model): - """Describes the list of Application Insights Resources. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of Application Insights component definitions. - :type value: - list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent] - :param next_link: The URI to get the next set of Application Insights component definitions if - too many components where returned in the result set. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationInsightsComponent]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class ApplicationInsightsComponentProactiveDetectionConfiguration(msrest.serialization.Model): - """A ProactiveDetection configuration definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :param name: Azure resource name. - :type name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :ivar name_properties_name: The rule name. - :vartype name_properties_name: str - :param enabled: A flag that indicates whether this rule is enabled by the user. - :type enabled: bool - :param send_emails_to_subscription_owners: A flag that indicated whether notifications on this - rule should be sent to subscription owners. - :type send_emails_to_subscription_owners: bool - :param custom_emails: Custom email addresses for this rule notifications. - :type custom_emails: list[str] - :ivar last_updated_time: The last time this rule was updated. - :vartype last_updated_time: str - :param rule_definitions: Static definitions of the ProactiveDetection configuration rule (same - values for all components). - :type rule_definitions: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name_properties_name': {'readonly': True}, - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.Name', 'type': 'str'}, - 'enabled': {'key': 'properties.Enabled', 'type': 'bool'}, - 'send_emails_to_subscription_owners': {'key': 'properties.SendEmailsToSubscriptionOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'properties.CustomEmails', 'type': '[str]'}, - 'last_updated_time': {'key': 'properties.LastUpdatedTime', 'type': 'str'}, - 'rule_definitions': {'key': 'properties.RuleDefinitions', 'type': 'ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentProactiveDetectionConfiguration, self).__init__(**kwargs) - self.id = None - self.name = kwargs.get('name', None) - self.type = None - self.location = kwargs.get('location', None) - self.name_properties_name = None - self.enabled = kwargs.get('enabled', None) - self.send_emails_to_subscription_owners = kwargs.get('send_emails_to_subscription_owners', None) - self.custom_emails = kwargs.get('custom_emails', None) - self.last_updated_time = None - self.rule_definitions = kwargs.get('rule_definitions', None) - - -class ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions(msrest.serialization.Model): - """Static definitions of the ProactiveDetection configuration rule (same values for all components). - - :param name: The rule name. - :type name: str - :param display_name: The rule name as it is displayed in UI. - :type display_name: str - :param description: The rule description. - :type description: str - :param help_url: URL which displays additional info about the proactive detection rule. - :type help_url: str - :param is_hidden: A flag indicating whether the rule is hidden (from the UI). - :type is_hidden: bool - :param is_enabled_by_default: A flag indicating whether the rule is enabled by default. - :type is_enabled_by_default: bool - :param is_in_preview: A flag indicating whether the rule is in preview. - :type is_in_preview: bool - :param supports_email_notifications: A flag indicating whether email notifications are - supported for detections for this rule. - :type supports_email_notifications: bool - """ - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'display_name': {'key': 'DisplayName', 'type': 'str'}, - 'description': {'key': 'Description', 'type': 'str'}, - 'help_url': {'key': 'HelpUrl', 'type': 'str'}, - 'is_hidden': {'key': 'IsHidden', 'type': 'bool'}, - 'is_enabled_by_default': {'key': 'IsEnabledByDefault', 'type': 'bool'}, - 'is_in_preview': {'key': 'IsInPreview', 'type': 'bool'}, - 'supports_email_notifications': {'key': 'SupportsEmailNotifications', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.help_url = kwargs.get('help_url', None) - self.is_hidden = kwargs.get('is_hidden', None) - self.is_enabled_by_default = kwargs.get('is_enabled_by_default', None) - self.is_in_preview = kwargs.get('is_in_preview', None) - self.supports_email_notifications = kwargs.get('supports_email_notifications', None) - - -class ComponentPurgeBody(msrest.serialization.Model): - """Describes the body of a purge request for an App Insights component. - - All required parameters must be populated in order to send to Azure. - - :param table: Required. Table from which to purge data. - :type table: str - :param filters: Required. The set of columns and filters (queries) to run over them to purge - the resulting data. - :type filters: - list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeBodyFilters] - """ - - _validation = { - 'table': {'required': True}, - 'filters': {'required': True}, - } - - _attribute_map = { - 'table': {'key': 'table', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': '[ComponentPurgeBodyFilters]'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeBody, self).__init__(**kwargs) - self.table = kwargs['table'] - self.filters = kwargs['filters'] - - -class ComponentPurgeBodyFilters(msrest.serialization.Model): - """User-defined filters to return data which will be purged from the table. - - :param column: The column of the table over which the given query should run. - :type column: str - :param operator: A query operator to evaluate over the provided column and value(s). Supported - operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would - in a KQL query. - :type operator: str - :param value: the value for the operator to function over. This can be a number (e.g., > 100), - a string (timestamp >= '2017-09-01') or array of values. - :type value: any - :param key: When filtering over custom dimensions, this key will be used as the name of the - custom dimension. - :type key: str - """ - - _attribute_map = { - 'column': {'key': 'column', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'object'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeBodyFilters, self).__init__(**kwargs) - self.column = kwargs.get('column', None) - self.operator = kwargs.get('operator', None) - self.value = kwargs.get('value', None) - self.key = kwargs.get('key', None) - - -class ComponentPurgeResponse(msrest.serialization.Model): - """Response containing operationId for a specific purge action. - - All required parameters must be populated in order to send to Azure. - - :param operation_id: Required. Id to use when querying for status for a particular purge - operation. - :type operation_id: str - """ - - _validation = { - 'operation_id': {'required': True}, - } - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeResponse, self).__init__(**kwargs) - self.operation_id = kwargs['operation_id'] - - -class ComponentPurgeStatusResponse(msrest.serialization.Model): - """Response containing status for a specific purge operation. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the operation represented by the requested Id. Possible - values include: "pending", "completed". - :type status: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PurgeState - """ - - _validation = { - 'status': {'required': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeStatusResponse, self).__init__(**kwargs) - self.status = kwargs['status'] - - -class HeaderField(msrest.serialization.Model): - """A header to add to the WebTest. - - :param header_field_name: The name of the header. - :type header_field_name: str - :param header_field_value: The value of the header. - :type header_field_value: str - """ - - _attribute_map = { - 'header_field_name': {'key': 'key', 'type': 'str'}, - 'header_field_value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HeaderField, self).__init__(**kwargs) - self.header_field_name = kwargs.get('header_field_name', None) - self.header_field_value = kwargs.get('header_field_value', None) - - -class Operation(msrest.serialization.Model): - """Represents an operation returned by the GetOperations request. - - :param name: Name of the operation. - :type name: str - :param display: Display name of the operation. - :type display: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationInfo - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: any - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationInfo'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class OperationInfo(msrest.serialization.Model): - """Information about an operation. - - :param provider: Name of the provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the operation. - :type operation: str - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInfo, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsListResult(msrest.serialization.Model): - """Result of the List Operations operation. - - :param value: A collection of operations. - :type value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PrivateLinkScopedResource(msrest.serialization.Model): - """The private link scope resource reference. - - :param resource_id: The full resource Id of the private link scope resource. - :type resource_id: str - :param scope_id: The private link scope unique Identifier. - :type scope_id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'ResourceId', 'type': 'str'}, - 'scope_id': {'key': 'ScopeId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkScopedResource, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.scope_id = kwargs.get('scope_id', None) - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on a WebTest instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class WebtestsResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(WebtestsResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class WebTest(WebtestsResource): - """An Application Insights WebTest definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of WebTest that this web test watches. Choices are ping and multistep. - Possible values include: "ping", "multistep". Default value: "ping". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestKind - :param synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as the - Name field. - :type synthetic_monitor_id: str - :param web_test_name: User defined name if this WebTest. - :type web_test_name: str - :param description: User defined description for this WebTest. - :type description: str - :param enabled: Is the test actively being monitored. - :type enabled: bool - :param frequency: Interval in seconds between test runs for this WebTest. Default value is 300. - :type frequency: int - :param timeout: Seconds until this WebTest will timeout and fail. Default value is 30. - :type timeout: int - :param web_test_kind: The kind of web test this is, valid choices are ping, multistep, basic, - and standard. Possible values include: "ping", "multistep", "basic", "standard". Default value: - "ping". - :type web_test_kind: str or - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestKindEnum - :param retry_enabled: Allow for retries should this WebTest fail. - :type retry_enabled: bool - :param locations: A list of where to physically run the tests from to give global coverage for - accessibility of your application. - :type locations: - list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestGeolocation] - :param configuration: An XML configuration specification for a WebTest. - :type configuration: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesConfiguration - :ivar provisioning_state: Current state of this component, whether or not is has been - provisioned within the resource group it is defined. Users cannot change this value but are - able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. - :vartype provisioning_state: str - :param request: The collection of request properties. - :type request: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesRequest - :param validation_rules: The collection of validation rule properties. - :type validation_rules: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesValidationRules - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'synthetic_monitor_id': {'key': 'properties.SyntheticMonitorId', 'type': 'str'}, - 'web_test_name': {'key': 'properties.Name', 'type': 'str'}, - 'description': {'key': 'properties.Description', 'type': 'str'}, - 'enabled': {'key': 'properties.Enabled', 'type': 'bool'}, - 'frequency': {'key': 'properties.Frequency', 'type': 'int'}, - 'timeout': {'key': 'properties.Timeout', 'type': 'int'}, - 'web_test_kind': {'key': 'properties.Kind', 'type': 'str'}, - 'retry_enabled': {'key': 'properties.RetryEnabled', 'type': 'bool'}, - 'locations': {'key': 'properties.Locations', 'type': '[WebTestGeolocation]'}, - 'configuration': {'key': 'properties.Configuration', 'type': 'WebTestPropertiesConfiguration'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request': {'key': 'properties.Request', 'type': 'WebTestPropertiesRequest'}, - 'validation_rules': {'key': 'properties.ValidationRules', 'type': 'WebTestPropertiesValidationRules'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTest, self).__init__(**kwargs) - self.kind = kwargs.get('kind', "ping") - self.synthetic_monitor_id = kwargs.get('synthetic_monitor_id', None) - self.web_test_name = kwargs.get('web_test_name', None) - self.description = kwargs.get('description', None) - self.enabled = kwargs.get('enabled', None) - self.frequency = kwargs.get('frequency', 300) - self.timeout = kwargs.get('timeout', 30) - self.web_test_kind = kwargs.get('web_test_kind', "ping") - self.retry_enabled = kwargs.get('retry_enabled', None) - self.locations = kwargs.get('locations', None) - self.configuration = kwargs.get('configuration', None) - self.provisioning_state = None - self.request = kwargs.get('request', None) - self.validation_rules = kwargs.get('validation_rules', None) - - -class WebTestGeolocation(msrest.serialization.Model): - """Geo-physical location to run a WebTest from. You must specify one or more locations for the test to run from. - - :param location: Location ID for the WebTest to run from. - :type location: str - """ - - _attribute_map = { - 'location': {'key': 'Id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestGeolocation, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - - -class WebTestListResult(msrest.serialization.Model): - """A list of 0 or more Application Insights WebTest definitions. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. Set of Application Insights WebTest definitions. - :type value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] - :param next_link: The link to get the next part of the returned list of WebTest, should the - return set be too large for a single request. May be null. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WebTest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class WebTestPropertiesConfiguration(msrest.serialization.Model): - """An XML configuration specification for a WebTest. - - :param web_test: The XML specification of a WebTest to run against an application. - :type web_test: str - """ - - _attribute_map = { - 'web_test': {'key': 'WebTest', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestPropertiesConfiguration, self).__init__(**kwargs) - self.web_test = kwargs.get('web_test', None) - - -class WebTestPropertiesRequest(msrest.serialization.Model): - """The collection of request properties. - - :param request_url: Url location to test. - :type request_url: str - :param headers: List of headers and their values to add to the WebTest call. - :type headers: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.HeaderField] - :param http_verb: Http verb to use for this web test. - :type http_verb: str - :param request_body: Base64 encoded string body to send with this web test. - :type request_body: str - :param parse_dependent_requests: Parse Dependent request for this WebTest. - :type parse_dependent_requests: bool - :param follow_redirects: Follow redirects for this web test. - :type follow_redirects: bool - """ - - _attribute_map = { - 'request_url': {'key': 'RequestUrl', 'type': 'str'}, - 'headers': {'key': 'Headers', 'type': '[HeaderField]'}, - 'http_verb': {'key': 'HttpVerb', 'type': 'str'}, - 'request_body': {'key': 'RequestBody', 'type': 'str'}, - 'parse_dependent_requests': {'key': 'ParseDependentRequests', 'type': 'bool'}, - 'follow_redirects': {'key': 'FollowRedirects', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestPropertiesRequest, self).__init__(**kwargs) - self.request_url = kwargs.get('request_url', None) - self.headers = kwargs.get('headers', None) - self.http_verb = kwargs.get('http_verb', None) - self.request_body = kwargs.get('request_body', None) - self.parse_dependent_requests = kwargs.get('parse_dependent_requests', None) - self.follow_redirects = kwargs.get('follow_redirects', None) - - -class WebTestPropertiesValidationRules(msrest.serialization.Model): - """The collection of validation rule properties. - - :param content_validation: The collection of content validation properties. - :type content_validation: - ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesValidationRulesContentValidation - :param ssl_check: Checks to see if the SSL cert is still valid. - :type ssl_check: bool - :param ssl_cert_remaining_lifetime_check: A number of days to check still remain before the the - existing SSL cert expires. Value must be positive and the SSLCheck must be set to true. - :type ssl_cert_remaining_lifetime_check: int - :param expected_http_status_code: Validate that the WebTest returns the http status code - provided. - :type expected_http_status_code: int - :param ignore_https_status_code: When set, validation will ignore the status code. - :type ignore_https_status_code: bool - """ - - _attribute_map = { - 'content_validation': {'key': 'ContentValidation', 'type': 'WebTestPropertiesValidationRulesContentValidation'}, - 'ssl_check': {'key': 'SSLCheck', 'type': 'bool'}, - 'ssl_cert_remaining_lifetime_check': {'key': 'SSLCertRemainingLifetimeCheck', 'type': 'int'}, - 'expected_http_status_code': {'key': 'ExpectedHttpStatusCode', 'type': 'int'}, - 'ignore_https_status_code': {'key': 'IgnoreHttpsStatusCode', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestPropertiesValidationRules, self).__init__(**kwargs) - self.content_validation = kwargs.get('content_validation', None) - self.ssl_check = kwargs.get('ssl_check', None) - self.ssl_cert_remaining_lifetime_check = kwargs.get('ssl_cert_remaining_lifetime_check', None) - self.expected_http_status_code = kwargs.get('expected_http_status_code', None) - self.ignore_https_status_code = kwargs.get('ignore_https_status_code', None) - - -class WebTestPropertiesValidationRulesContentValidation(msrest.serialization.Model): - """The collection of content validation properties. - - :param content_match: Content to look for in the return of the WebTest. Must not be null or - empty. - :type content_match: str - :param ignore_case: When set, this value makes the ContentMatch validation case insensitive. - :type ignore_case: bool - :param pass_if_text_found: When true, validation will pass if there is a match for the - ContentMatch string. If false, validation will fail if there is a match. - :type pass_if_text_found: bool - """ - - _attribute_map = { - 'content_match': {'key': 'ContentMatch', 'type': 'str'}, - 'ignore_case': {'key': 'IgnoreCase', 'type': 'bool'}, - 'pass_if_text_found': {'key': 'PassIfTextFound', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(WebTestPropertiesValidationRulesContentValidation, self).__init__(**kwargs) - self.content_match = kwargs.get('content_match', None) - self.ignore_case = kwargs.get('ignore_case', None) - self.pass_if_text_found = kwargs.get('pass_if_text_found', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py index a2df578a179da..0265625c33528 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/models/_models_py3.py @@ -26,10 +26,10 @@ class ComponentsResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -54,6 +54,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ComponentsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -75,31 +81,31 @@ class ApplicationInsightsComponent(ComponentsResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. The kind of application that this component refers to, used to customize + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone. - :type kind: str + :vartype kind: str :ivar application_id: The unique ID of your application. This field mirrors the 'Name' field and cannot be changed. :vartype application_id: str :ivar app_id: Application Insights Unique ID for your Application. :vartype app_id: str - :param application_type: Type of application being monitored. Possible values include: "web", + :ivar application_type: Type of application being monitored. Possible values include: "web", "other". Default value: "web". - :type application_type: str or + :vartype application_type: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationType - :param flow_type: Used by the Application Insights system to determine what kind of flow this + :ivar flow_type: Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". - :type flow_type: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.FlowType - :param request_source: Describes what tool created this Application Insights component. + :vartype flow_type: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.FlowType + :ivar request_source: Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. Possible values include: "rest". Default value: "rest". - :type request_source: str or + :vartype request_source: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.RequestSource :ivar instrumentation_key: Application Insights Instrumentation key. A read-only value that applications can use to identify the destination for all telemetry sent to Azure Application @@ -110,9 +116,9 @@ class ApplicationInsightsComponent(ComponentsResource): :vartype creation_date: ~datetime.datetime :ivar tenant_id: Azure Tenant Id. :vartype tenant_id: str - :param hockey_app_id: The unique application ID created when a new application is added to + :ivar hockey_app_id: The unique application ID created when a new application is added to HockeyApp, used for communications with HockeyApp. - :type hockey_app_id: str + :vartype hockey_app_id: str :ivar hockey_app_token: Token used to authenticate communications with between Application Insights and HockeyApp. :vartype hockey_app_token: str @@ -120,32 +126,32 @@ class ApplicationInsightsComponent(ComponentsResource): provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. :vartype provisioning_state: str - :param sampling_percentage: Percentage of the data produced by the application being monitored + :ivar sampling_percentage: Percentage of the data produced by the application being monitored that is being sampled for Application Insights telemetry. - :type sampling_percentage: float + :vartype sampling_percentage: float :ivar connection_string: Application Insights component connection string. :vartype connection_string: str - :param retention_in_days: Retention period in days. - :type retention_in_days: int - :param disable_ip_masking: Disable IP masking. - :type disable_ip_masking: bool - :param immediate_purge_data_on30_days: Purge data immediately after 30 days. - :type immediate_purge_data_on30_days: bool + :ivar retention_in_days: Retention period in days. + :vartype retention_in_days: int + :ivar disable_ip_masking: Disable IP masking. + :vartype disable_ip_masking: bool + :ivar immediate_purge_data_on30_days: Purge data immediately after 30 days. + :vartype immediate_purge_data_on30_days: bool :ivar private_link_scoped_resources: List of linked private link scope resources. :vartype private_link_scoped_resources: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PrivateLinkScopedResource] - :param public_network_access_for_ingestion: The network access type for accessing Application + :ivar public_network_access_for_ingestion: The network access type for accessing Application Insights ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_ingestion: str or + :vartype public_network_access_for_ingestion: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PublicNetworkAccessType - :param public_network_access_for_query: The network access type for accessing Application + :ivar public_network_access_for_query: The network access type for accessing Application Insights query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_query: str or + :vartype public_network_access_for_query: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PublicNetworkAccessType - :param ingestion_mode: Indicates the flow of the ingestion. Possible values include: + :ivar ingestion_mode: Indicates the flow of the ingestion. Possible values include: "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default value: "ApplicationInsights". - :type ingestion_mode: str or + :vartype ingestion_mode: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.IngestionMode """ @@ -214,6 +220,55 @@ def __init__( ingestion_mode: Optional[Union[str, "IngestionMode"]] = "ApplicationInsights", **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Required. The kind of application that this component refers to, used to + customize UI. This value is a freeform string, values should typically be one of the following: + web, ios, other, store, java, phone. + :paramtype kind: str + :keyword application_type: Type of application being monitored. Possible values include: "web", + "other". Default value: "web". + :paramtype application_type: str or + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationType + :keyword flow_type: Used by the Application Insights system to determine what kind of flow this + component was created by. This is to be set to 'Bluefield' when creating/updating a component + via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". + :paramtype flow_type: str or + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.FlowType + :keyword request_source: Describes what tool created this Application Insights component. + Customers using this API should set this to the default 'rest'. Possible values include: + "rest". Default value: "rest". + :paramtype request_source: str or + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.RequestSource + :keyword hockey_app_id: The unique application ID created when a new application is added to + HockeyApp, used for communications with HockeyApp. + :paramtype hockey_app_id: str + :keyword sampling_percentage: Percentage of the data produced by the application being + monitored that is being sampled for Application Insights telemetry. + :paramtype sampling_percentage: float + :keyword retention_in_days: Retention period in days. + :paramtype retention_in_days: int + :keyword disable_ip_masking: Disable IP masking. + :paramtype disable_ip_masking: bool + :keyword immediate_purge_data_on30_days: Purge data immediately after 30 days. + :paramtype immediate_purge_data_on30_days: bool + :keyword public_network_access_for_ingestion: The network access type for accessing Application + Insights ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype public_network_access_for_ingestion: str or + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PublicNetworkAccessType + :keyword public_network_access_for_query: The network access type for accessing Application + Insights query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype public_network_access_for_query: str or + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PublicNetworkAccessType + :keyword ingestion_mode: Indicates the flow of the ingestion. Possible values include: + "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default + value: "ApplicationInsights". + :paramtype ingestion_mode: str or + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.IngestionMode + """ super(ApplicationInsightsComponent, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.application_id = None @@ -243,12 +298,12 @@ class ApplicationInsightsComponentListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of Application Insights component definitions. - :type value: + :ivar value: Required. List of Application Insights component definitions. + :vartype value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent] - :param next_link: The URI to get the next set of Application Insights component definitions if + :ivar next_link: The URI to get the next set of Application Insights component definitions if too many components where returned in the result set. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -267,6 +322,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. List of Application Insights component definitions. + :paramtype value: + list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent] + :keyword next_link: The URI to get the next set of Application Insights component definitions + if too many components where returned in the result set. + :paramtype next_link: str + """ super(ApplicationInsightsComponentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -279,26 +342,26 @@ class ApplicationInsightsComponentProactiveDetectionConfiguration(msrest.seriali :ivar id: Azure resource Id. :vartype id: str - :param name: Azure resource name. - :type name: str + :ivar name: Azure resource name. + :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar name_properties_name: The rule name. :vartype name_properties_name: str - :param enabled: A flag that indicates whether this rule is enabled by the user. - :type enabled: bool - :param send_emails_to_subscription_owners: A flag that indicated whether notifications on this + :ivar enabled: A flag that indicates whether this rule is enabled by the user. + :vartype enabled: bool + :ivar send_emails_to_subscription_owners: A flag that indicated whether notifications on this rule should be sent to subscription owners. - :type send_emails_to_subscription_owners: bool - :param custom_emails: Custom email addresses for this rule notifications. - :type custom_emails: list[str] + :vartype send_emails_to_subscription_owners: bool + :ivar custom_emails: Custom email addresses for this rule notifications. + :vartype custom_emails: list[str] :ivar last_updated_time: The last time this rule was updated. :vartype last_updated_time: str - :param rule_definitions: Static definitions of the ProactiveDetection configuration rule (same + :ivar rule_definitions: Static definitions of the ProactiveDetection configuration rule (same values for all components). - :type rule_definitions: + :vartype rule_definitions: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions """ @@ -333,6 +396,23 @@ def __init__( rule_definitions: Optional["ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions"] = None, **kwargs ): + """ + :keyword name: Azure resource name. + :paramtype name: str + :keyword location: Resource location. + :paramtype location: str + :keyword enabled: A flag that indicates whether this rule is enabled by the user. + :paramtype enabled: bool + :keyword send_emails_to_subscription_owners: A flag that indicated whether notifications on + this rule should be sent to subscription owners. + :paramtype send_emails_to_subscription_owners: bool + :keyword custom_emails: Custom email addresses for this rule notifications. + :paramtype custom_emails: list[str] + :keyword rule_definitions: Static definitions of the ProactiveDetection configuration rule + (same values for all components). + :paramtype rule_definitions: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions + """ super(ApplicationInsightsComponentProactiveDetectionConfiguration, self).__init__(**kwargs) self.id = None self.name = name @@ -349,23 +429,23 @@ def __init__( class ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions(msrest.serialization.Model): """Static definitions of the ProactiveDetection configuration rule (same values for all components). - :param name: The rule name. - :type name: str - :param display_name: The rule name as it is displayed in UI. - :type display_name: str - :param description: The rule description. - :type description: str - :param help_url: URL which displays additional info about the proactive detection rule. - :type help_url: str - :param is_hidden: A flag indicating whether the rule is hidden (from the UI). - :type is_hidden: bool - :param is_enabled_by_default: A flag indicating whether the rule is enabled by default. - :type is_enabled_by_default: bool - :param is_in_preview: A flag indicating whether the rule is in preview. - :type is_in_preview: bool - :param supports_email_notifications: A flag indicating whether email notifications are - supported for detections for this rule. - :type supports_email_notifications: bool + :ivar name: The rule name. + :vartype name: str + :ivar display_name: The rule name as it is displayed in UI. + :vartype display_name: str + :ivar description: The rule description. + :vartype description: str + :ivar help_url: URL which displays additional info about the proactive detection rule. + :vartype help_url: str + :ivar is_hidden: A flag indicating whether the rule is hidden (from the UI). + :vartype is_hidden: bool + :ivar is_enabled_by_default: A flag indicating whether the rule is enabled by default. + :vartype is_enabled_by_default: bool + :ivar is_in_preview: A flag indicating whether the rule is in preview. + :vartype is_in_preview: bool + :ivar supports_email_notifications: A flag indicating whether email notifications are supported + for detections for this rule. + :vartype supports_email_notifications: bool """ _attribute_map = { @@ -392,6 +472,25 @@ def __init__( supports_email_notifications: Optional[bool] = None, **kwargs ): + """ + :keyword name: The rule name. + :paramtype name: str + :keyword display_name: The rule name as it is displayed in UI. + :paramtype display_name: str + :keyword description: The rule description. + :paramtype description: str + :keyword help_url: URL which displays additional info about the proactive detection rule. + :paramtype help_url: str + :keyword is_hidden: A flag indicating whether the rule is hidden (from the UI). + :paramtype is_hidden: bool + :keyword is_enabled_by_default: A flag indicating whether the rule is enabled by default. + :paramtype is_enabled_by_default: bool + :keyword is_in_preview: A flag indicating whether the rule is in preview. + :paramtype is_in_preview: bool + :keyword supports_email_notifications: A flag indicating whether email notifications are + supported for detections for this rule. + :paramtype supports_email_notifications: bool + """ super(ApplicationInsightsComponentProactiveDetectionConfigurationPropertiesRuleDefinitions, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -408,11 +507,11 @@ class ComponentPurgeBody(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param table: Required. Table from which to purge data. - :type table: str - :param filters: Required. The set of columns and filters (queries) to run over them to purge - the resulting data. - :type filters: + :ivar table: Required. Table from which to purge data. + :vartype table: str + :ivar filters: Required. The set of columns and filters (queries) to run over them to purge the + resulting data. + :vartype filters: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeBodyFilters] """ @@ -433,6 +532,14 @@ def __init__( filters: List["ComponentPurgeBodyFilters"], **kwargs ): + """ + :keyword table: Required. Table from which to purge data. + :paramtype table: str + :keyword filters: Required. The set of columns and filters (queries) to run over them to purge + the resulting data. + :paramtype filters: + list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ComponentPurgeBodyFilters] + """ super(ComponentPurgeBody, self).__init__(**kwargs) self.table = table self.filters = filters @@ -441,18 +548,18 @@ def __init__( class ComponentPurgeBodyFilters(msrest.serialization.Model): """User-defined filters to return data which will be purged from the table. - :param column: The column of the table over which the given query should run. - :type column: str - :param operator: A query operator to evaluate over the provided column and value(s). Supported + :ivar column: The column of the table over which the given query should run. + :vartype column: str + :ivar operator: A query operator to evaluate over the provided column and value(s). Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would in a KQL query. - :type operator: str - :param value: the value for the operator to function over. This can be a number (e.g., > 100), - a string (timestamp >= '2017-09-01') or array of values. - :type value: any - :param key: When filtering over custom dimensions, this key will be used as the name of the + :vartype operator: str + :ivar value: the value for the operator to function over. This can be a number (e.g., > 100), a + string (timestamp >= '2017-09-01') or array of values. + :vartype value: any + :ivar key: When filtering over custom dimensions, this key will be used as the name of the custom dimension. - :type key: str + :vartype key: str """ _attribute_map = { @@ -471,6 +578,20 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword column: The column of the table over which the given query should run. + :paramtype column: str + :keyword operator: A query operator to evaluate over the provided column and value(s). + Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as + they would in a KQL query. + :paramtype operator: str + :keyword value: the value for the operator to function over. This can be a number (e.g., > + 100), a string (timestamp >= '2017-09-01') or array of values. + :paramtype value: any + :keyword key: When filtering over custom dimensions, this key will be used as the name of the + custom dimension. + :paramtype key: str + """ super(ComponentPurgeBodyFilters, self).__init__(**kwargs) self.column = column self.operator = operator @@ -483,9 +604,9 @@ class ComponentPurgeResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param operation_id: Required. Id to use when querying for status for a particular purge + :ivar operation_id: Required. Id to use when querying for status for a particular purge operation. - :type operation_id: str + :vartype operation_id: str """ _validation = { @@ -502,6 +623,11 @@ def __init__( operation_id: str, **kwargs ): + """ + :keyword operation_id: Required. Id to use when querying for status for a particular purge + operation. + :paramtype operation_id: str + """ super(ComponentPurgeResponse, self).__init__(**kwargs) self.operation_id = operation_id @@ -511,9 +637,9 @@ class ComponentPurgeStatusResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the operation represented by the requested Id. Possible + :ivar status: Required. Status of the operation represented by the requested Id. Possible values include: "pending", "completed". - :type status: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PurgeState + :vartype status: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PurgeState """ _validation = { @@ -530,6 +656,11 @@ def __init__( status: Union[str, "PurgeState"], **kwargs ): + """ + :keyword status: Required. Status of the operation represented by the requested Id. Possible + values include: "pending", "completed". + :paramtype status: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.PurgeState + """ super(ComponentPurgeStatusResponse, self).__init__(**kwargs) self.status = status @@ -537,10 +668,10 @@ def __init__( class HeaderField(msrest.serialization.Model): """A header to add to the WebTest. - :param header_field_name: The name of the header. - :type header_field_name: str - :param header_field_value: The value of the header. - :type header_field_value: str + :ivar header_field_name: The name of the header. + :vartype header_field_name: str + :ivar header_field_value: The value of the header. + :vartype header_field_value: str """ _attribute_map = { @@ -555,6 +686,12 @@ def __init__( header_field_value: Optional[str] = None, **kwargs ): + """ + :keyword header_field_name: The name of the header. + :paramtype header_field_name: str + :keyword header_field_value: The value of the header. + :paramtype header_field_value: str + """ super(HeaderField, self).__init__(**kwargs) self.header_field_name = header_field_name self.header_field_value = header_field_value @@ -563,14 +700,14 @@ def __init__( class Operation(msrest.serialization.Model): """Represents an operation returned by the GetOperations request. - :param name: Name of the operation. - :type name: str - :param display: Display name of the operation. - :type display: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationInfo - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: any + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Display name of the operation. + :vartype display: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationInfo + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: any """ _attribute_map = { @@ -589,6 +726,16 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Display name of the operation. + :paramtype display: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationInfo + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: any + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -599,14 +746,14 @@ def __init__( class OperationInfo(msrest.serialization.Model): """Information about an operation. - :param provider: Name of the provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the operation. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Name of the provider. + :vartype provider: str + :ivar resource: Name of the resource type. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -625,6 +772,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Name of the provider. + :paramtype provider: str + :keyword resource: Name of the resource type. + :paramtype resource: str + :keyword operation: Name of the operation. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationInfo, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -635,10 +792,10 @@ def __init__( class OperationsListResult(msrest.serialization.Model): """Result of the List Operations operation. - :param value: A collection of operations. - :type value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: A collection of operations. + :vartype value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -653,6 +810,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of operations. + :paramtype value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -661,10 +824,10 @@ def __init__( class PrivateLinkScopedResource(msrest.serialization.Model): """The private link scope resource reference. - :param resource_id: The full resource Id of the private link scope resource. - :type resource_id: str - :param scope_id: The private link scope unique Identifier. - :type scope_id: str + :ivar resource_id: The full resource Id of the private link scope resource. + :vartype resource_id: str + :ivar scope_id: The private link scope unique Identifier. + :vartype scope_id: str """ _attribute_map = { @@ -679,6 +842,12 @@ def __init__( scope_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: The full resource Id of the private link scope resource. + :paramtype resource_id: str + :keyword scope_id: The private link scope unique Identifier. + :paramtype scope_id: str + """ super(PrivateLinkScopedResource, self).__init__(**kwargs) self.resource_id = resource_id self.scope_id = scope_id @@ -687,8 +856,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a WebTest instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -701,6 +870,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -718,10 +891,10 @@ class WebtestsResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -746,6 +919,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(WebtestsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -767,49 +946,49 @@ class WebTest(WebtestsResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of WebTest that this web test watches. Choices are ping and multistep. + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of WebTest that this web test watches. Choices are ping and multistep. Possible values include: "ping", "multistep". Default value: "ping". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestKind - :param synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as the + :vartype kind: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestKind + :ivar synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as the Name field. - :type synthetic_monitor_id: str - :param web_test_name: User defined name if this WebTest. - :type web_test_name: str - :param description: User defined description for this WebTest. - :type description: str - :param enabled: Is the test actively being monitored. - :type enabled: bool - :param frequency: Interval in seconds between test runs for this WebTest. Default value is 300. - :type frequency: int - :param timeout: Seconds until this WebTest will timeout and fail. Default value is 30. - :type timeout: int - :param web_test_kind: The kind of web test this is, valid choices are ping, multistep, basic, + :vartype synthetic_monitor_id: str + :ivar web_test_name: User defined name if this WebTest. + :vartype web_test_name: str + :ivar description: User defined description for this WebTest. + :vartype description: str + :ivar enabled: Is the test actively being monitored. + :vartype enabled: bool + :ivar frequency: Interval in seconds between test runs for this WebTest. Default value is 300. + :vartype frequency: int + :ivar timeout: Seconds until this WebTest will timeout and fail. Default value is 30. + :vartype timeout: int + :ivar web_test_kind: The kind of web test this is, valid choices are ping, multistep, basic, and standard. Possible values include: "ping", "multistep", "basic", "standard". Default value: "ping". - :type web_test_kind: str or + :vartype web_test_kind: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestKindEnum - :param retry_enabled: Allow for retries should this WebTest fail. - :type retry_enabled: bool - :param locations: A list of where to physically run the tests from to give global coverage for + :ivar retry_enabled: Allow for retries should this WebTest fail. + :vartype retry_enabled: bool + :ivar locations: A list of where to physically run the tests from to give global coverage for accessibility of your application. - :type locations: + :vartype locations: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestGeolocation] - :param configuration: An XML configuration specification for a WebTest. - :type configuration: + :ivar configuration: An XML configuration specification for a WebTest. + :vartype configuration: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesConfiguration :ivar provisioning_state: Current state of this component, whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. :vartype provisioning_state: str - :param request: The collection of request properties. - :type request: + :ivar request: The collection of request properties. + :vartype request: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesRequest - :param validation_rules: The collection of validation rule properties. - :type validation_rules: + :ivar validation_rules: The collection of validation rule properties. + :vartype validation_rules: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesValidationRules """ @@ -863,6 +1042,49 @@ def __init__( validation_rules: Optional["WebTestPropertiesValidationRules"] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of WebTest that this web test watches. Choices are ping and multistep. + Possible values include: "ping", "multistep". Default value: "ping". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestKind + :keyword synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as + the Name field. + :paramtype synthetic_monitor_id: str + :keyword web_test_name: User defined name if this WebTest. + :paramtype web_test_name: str + :keyword description: User defined description for this WebTest. + :paramtype description: str + :keyword enabled: Is the test actively being monitored. + :paramtype enabled: bool + :keyword frequency: Interval in seconds between test runs for this WebTest. Default value is + 300. + :paramtype frequency: int + :keyword timeout: Seconds until this WebTest will timeout and fail. Default value is 30. + :paramtype timeout: int + :keyword web_test_kind: The kind of web test this is, valid choices are ping, multistep, basic, + and standard. Possible values include: "ping", "multistep", "basic", "standard". Default value: + "ping". + :paramtype web_test_kind: str or + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestKindEnum + :keyword retry_enabled: Allow for retries should this WebTest fail. + :paramtype retry_enabled: bool + :keyword locations: A list of where to physically run the tests from to give global coverage + for accessibility of your application. + :paramtype locations: + list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestGeolocation] + :keyword configuration: An XML configuration specification for a WebTest. + :paramtype configuration: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesConfiguration + :keyword request: The collection of request properties. + :paramtype request: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesRequest + :keyword validation_rules: The collection of validation rule properties. + :paramtype validation_rules: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesValidationRules + """ super(WebTest, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.synthetic_monitor_id = synthetic_monitor_id @@ -883,8 +1105,8 @@ def __init__( class WebTestGeolocation(msrest.serialization.Model): """Geo-physical location to run a WebTest from. You must specify one or more locations for the test to run from. - :param location: Location ID for the WebTest to run from. - :type location: str + :ivar location: Location ID for the WebTest to run from. + :vartype location: str """ _attribute_map = { @@ -897,6 +1119,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: Location ID for the WebTest to run from. + :paramtype location: str + """ super(WebTestGeolocation, self).__init__(**kwargs) self.location = location @@ -906,11 +1132,11 @@ class WebTestListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. Set of Application Insights WebTest definitions. - :type value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] - :param next_link: The link to get the next part of the returned list of WebTest, should the + :ivar value: Required. Set of Application Insights WebTest definitions. + :vartype value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] + :ivar next_link: The link to get the next part of the returned list of WebTest, should the return set be too large for a single request. May be null. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -929,6 +1155,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. Set of Application Insights WebTest definitions. + :paramtype value: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTest] + :keyword next_link: The link to get the next part of the returned list of WebTest, should the + return set be too large for a single request. May be null. + :paramtype next_link: str + """ super(WebTestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -937,8 +1170,8 @@ def __init__( class WebTestPropertiesConfiguration(msrest.serialization.Model): """An XML configuration specification for a WebTest. - :param web_test: The XML specification of a WebTest to run against an application. - :type web_test: str + :ivar web_test: The XML specification of a WebTest to run against an application. + :vartype web_test: str """ _attribute_map = { @@ -951,6 +1184,10 @@ def __init__( web_test: Optional[str] = None, **kwargs ): + """ + :keyword web_test: The XML specification of a WebTest to run against an application. + :paramtype web_test: str + """ super(WebTestPropertiesConfiguration, self).__init__(**kwargs) self.web_test = web_test @@ -958,18 +1195,18 @@ def __init__( class WebTestPropertiesRequest(msrest.serialization.Model): """The collection of request properties. - :param request_url: Url location to test. - :type request_url: str - :param headers: List of headers and their values to add to the WebTest call. - :type headers: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.HeaderField] - :param http_verb: Http verb to use for this web test. - :type http_verb: str - :param request_body: Base64 encoded string body to send with this web test. - :type request_body: str - :param parse_dependent_requests: Parse Dependent request for this WebTest. - :type parse_dependent_requests: bool - :param follow_redirects: Follow redirects for this web test. - :type follow_redirects: bool + :ivar request_url: Url location to test. + :vartype request_url: str + :ivar headers: List of headers and their values to add to the WebTest call. + :vartype headers: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.HeaderField] + :ivar http_verb: Http verb to use for this web test. + :vartype http_verb: str + :ivar request_body: Base64 encoded string body to send with this web test. + :vartype request_body: str + :ivar parse_dependent_requests: Parse Dependent request for this WebTest. + :vartype parse_dependent_requests: bool + :ivar follow_redirects: Follow redirects for this web test. + :vartype follow_redirects: bool """ _attribute_map = { @@ -992,6 +1229,21 @@ def __init__( follow_redirects: Optional[bool] = None, **kwargs ): + """ + :keyword request_url: Url location to test. + :paramtype request_url: str + :keyword headers: List of headers and their values to add to the WebTest call. + :paramtype headers: + list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.HeaderField] + :keyword http_verb: Http verb to use for this web test. + :paramtype http_verb: str + :keyword request_body: Base64 encoded string body to send with this web test. + :paramtype request_body: str + :keyword parse_dependent_requests: Parse Dependent request for this WebTest. + :paramtype parse_dependent_requests: bool + :keyword follow_redirects: Follow redirects for this web test. + :paramtype follow_redirects: bool + """ super(WebTestPropertiesRequest, self).__init__(**kwargs) self.request_url = request_url self.headers = headers @@ -1004,19 +1256,19 @@ def __init__( class WebTestPropertiesValidationRules(msrest.serialization.Model): """The collection of validation rule properties. - :param content_validation: The collection of content validation properties. - :type content_validation: + :ivar content_validation: The collection of content validation properties. + :vartype content_validation: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesValidationRulesContentValidation - :param ssl_check: Checks to see if the SSL cert is still valid. - :type ssl_check: bool - :param ssl_cert_remaining_lifetime_check: A number of days to check still remain before the the + :ivar ssl_check: Checks to see if the SSL cert is still valid. + :vartype ssl_check: bool + :ivar ssl_cert_remaining_lifetime_check: A number of days to check still remain before the the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true. - :type ssl_cert_remaining_lifetime_check: int - :param expected_http_status_code: Validate that the WebTest returns the http status code + :vartype ssl_cert_remaining_lifetime_check: int + :ivar expected_http_status_code: Validate that the WebTest returns the http status code provided. - :type expected_http_status_code: int - :param ignore_https_status_code: When set, validation will ignore the status code. - :type ignore_https_status_code: bool + :vartype expected_http_status_code: int + :ivar ignore_https_status_code: When set, validation will ignore the status code. + :vartype ignore_https_status_code: bool """ _attribute_map = { @@ -1037,6 +1289,21 @@ def __init__( ignore_https_status_code: Optional[bool] = None, **kwargs ): + """ + :keyword content_validation: The collection of content validation properties. + :paramtype content_validation: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestPropertiesValidationRulesContentValidation + :keyword ssl_check: Checks to see if the SSL cert is still valid. + :paramtype ssl_check: bool + :keyword ssl_cert_remaining_lifetime_check: A number of days to check still remain before the + the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true. + :paramtype ssl_cert_remaining_lifetime_check: int + :keyword expected_http_status_code: Validate that the WebTest returns the http status code + provided. + :paramtype expected_http_status_code: int + :keyword ignore_https_status_code: When set, validation will ignore the status code. + :paramtype ignore_https_status_code: bool + """ super(WebTestPropertiesValidationRules, self).__init__(**kwargs) self.content_validation = content_validation self.ssl_check = ssl_check @@ -1048,14 +1315,14 @@ def __init__( class WebTestPropertiesValidationRulesContentValidation(msrest.serialization.Model): """The collection of content validation properties. - :param content_match: Content to look for in the return of the WebTest. Must not be null or + :ivar content_match: Content to look for in the return of the WebTest. Must not be null or empty. - :type content_match: str - :param ignore_case: When set, this value makes the ContentMatch validation case insensitive. - :type ignore_case: bool - :param pass_if_text_found: When true, validation will pass if there is a match for the + :vartype content_match: str + :ivar ignore_case: When set, this value makes the ContentMatch validation case insensitive. + :vartype ignore_case: bool + :ivar pass_if_text_found: When true, validation will pass if there is a match for the ContentMatch string. If false, validation will fail if there is a match. - :type pass_if_text_found: bool + :vartype pass_if_text_found: bool """ _attribute_map = { @@ -1072,6 +1339,16 @@ def __init__( pass_if_text_found: Optional[bool] = None, **kwargs ): + """ + :keyword content_match: Content to look for in the return of the WebTest. Must not be null or + empty. + :paramtype content_match: str + :keyword ignore_case: When set, this value makes the ContentMatch validation case insensitive. + :paramtype ignore_case: bool + :keyword pass_if_text_found: When true, validation will pass if there is a match for the + ContentMatch string. If false, validation will fail if there is a match. + :paramtype pass_if_text_found: bool + """ super(WebTestPropertiesValidationRulesContentValidation, self).__init__(**kwargs) self.content_match = content_match self.ignore_case = ignore_case diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py index 6156363605b31..d1090d1c504c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_components_operations.py @@ -5,23 +5,323 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_purge_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_purge_status_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + purge_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "purgeId": _SERIALIZER.url("purge_id", purge_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ComponentsOperations(object): """ComponentsOperations operations. @@ -45,16 +345,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsComponentListResult"] + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsComponentListResult"]: """Gets a list of all Application Insights components within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -62,34 +364,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,24 +404,27 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsComponentListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsComponentListResult"]: """Gets a list of Application Insights components within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -132,35 +432,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,18 +474,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Deletes an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -206,25 +503,17 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -237,13 +526,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Returns an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -260,27 +550,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -294,16 +574,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - insight_properties, # type: "_models.ApplicationInsightsComponent" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + insight_properties: "_models.ApplicationInsightsComponent", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Creates (or updates) an Application Insights component. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. @@ -313,7 +595,8 @@ def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. - :type insight_properties: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent + :type insight_properties: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponent @@ -324,32 +607,22 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -367,16 +640,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def update_tags( self, - resource_group_name, # type: str - resource_name, # type: str - component_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + component_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -395,32 +670,22 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(component_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(component_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -438,16 +703,18 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def purge( self, - resource_group_name, # type: str - resource_name, # type: str - body, # type: "_models.ComponentPurgeBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentPurgeResponse" + resource_group_name: str, + resource_name: str, + body: "_models.ComponentPurgeBody", + **kwargs: Any + ) -> "_models.ComponentPurgeResponse": """Purges data in an Application Insights component by a set of user-defined filters. In order to manage system resources, purge requests are throttled at 50 requests per hour. You @@ -473,32 +740,22 @@ def purge( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.purge.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ComponentPurgeBody') + + request = build_purge_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.purge.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ComponentPurgeBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -512,16 +769,18 @@ def purge( return cls(pipeline_response, deserialized, {}) return deserialized + purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'} # type: ignore + + @distributed_trace def get_purge_status( self, - resource_group_name, # type: str - resource_name, # type: str - purge_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentPurgeStatusResponse" + resource_group_name: str, + resource_name: str, + purge_id: str, + **kwargs: Any + ) -> "_models.ComponentPurgeStatusResponse": """Get status for an ongoing purge operation. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -541,28 +800,18 @@ def get_purge_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_purge_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'purgeId': self._serialize.url("purge_id", purge_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_purge_status_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + purge_id=purge_id, + template_url=self.get_purge_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -576,4 +825,6 @@ def get_purge_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py index 183ab17fb59eb..c0b93edafe42d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Insights/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,18 +72,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationsListResult"]: """List available operations. List the available operations supported by the Microsoft.EventGrid resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationsListResult] + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] @@ -64,30 +93,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,6 +131,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py index 70b00929e748f..3dfa08207dc2b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_proactive_detection_configurations_operations.py @@ -5,22 +5,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + configuration_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + configuration_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ProactiveDetectionConfigurationsOperations(object): """ProactiveDetectionConfigurationsOperations operations. @@ -44,13 +165,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"]: """Gets a list of ProactiveDetection configurations of an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -58,8 +179,10 @@ def list( :param resource_name: The name of the Application Insights component resource. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration] + :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"]] @@ -67,27 +190,17 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,16 +214,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - configuration_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration" + resource_group_name: str, + resource_name: str, + configuration_id: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration": """Get the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -121,8 +236,10 @@ def get( Application Insights component. :type configuration_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -130,28 +247,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,17 +272,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - configuration_id, # type: str - proactive_detection_properties, # type: "_models.ApplicationInsightsComponentProactiveDetectionConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration" + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: "_models.ApplicationInsightsComponentProactiveDetectionConfiguration", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponentProactiveDetectionConfiguration": """Update the ProactiveDetection configuration for this configuration id. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -187,10 +296,13 @@ def update( :type configuration_id: str :param proactive_detection_properties: Properties that need to be specified to update the ProactiveDetection configuration. - :type proactive_detection_properties: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :keyword callable cls: A custom type or function that will be passed the direct response - :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :return: ApplicationInsightsComponentProactiveDetectionConfiguration, or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.v2018_05_01_preview.models.ApplicationInsightsComponentProactiveDetectionConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentProactiveDetectionConfiguration"] @@ -198,33 +310,23 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'ConfigurationId': self._serialize.url("configuration_id", configuration_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + configuration_id=configuration_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(proactive_detection_properties, 'ApplicationInsightsComponentProactiveDetectionConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -238,4 +340,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py index a876db60007aa..69e9b95ee95c8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_05_01_preview/operations/_web_tests_operations.py @@ -5,23 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + web_test_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + subscription_id: str, + web_test_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + web_test_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + web_test_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_component_request( + component_name: str, + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests') + path_format_arguments = { + "componentName": _SERIALIZER.url("component_name", component_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WebTestsOperations(object): """WebTestsOperations operations. @@ -45,19 +299,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebTestListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WebTestListResult"]: """Get all Application Insights web tests defined within a specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -65,35 +320,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,18 +362,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - web_test_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WebTest" + resource_group_name: str, + web_test_name: str, + **kwargs: Any + ) -> "_models.WebTest": """Get a specific Application Insights web test definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -139,27 +391,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,16 +415,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - web_test_name, # type: str - web_test_definition, # type: "_models.WebTest" - **kwargs # type: Any - ): - # type: (...) -> "_models.WebTest" + resource_group_name: str, + web_test_name: str, + web_test_definition: "_models.WebTest", + **kwargs: Any + ) -> "_models.WebTest": """Creates or updates an Application Insights web test definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -202,32 +446,22 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(web_test_definition, 'WebTest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_definition, 'WebTest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -241,16 +475,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def update_tags( self, - resource_group_name, # type: str - web_test_name, # type: str - web_test_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.WebTest" + resource_group_name: str, + web_test_name: str, + web_test_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.WebTest": """Creates or updates an Application Insights web test definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -269,32 +505,22 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(web_test_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + web_test_name=web_test_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(web_test_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,15 +534,17 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - web_test_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + web_test_name: str, + **kwargs: Any + ) -> None: """Deletes an Application Insights web test. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -333,25 +561,17 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'webTestName': self._serialize.url("web_test_name", web_test_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + web_test_name=web_test_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -364,16 +584,18 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebTestListResult"] + **kwargs: Any + ) -> Iterable["_models.WebTestListResult"]: """Get all Application Insights web test alerts definitions within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -381,34 +603,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -426,18 +643,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests'} # type: ignore + @distributed_trace def list_by_component( self, - component_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebTestListResult"] + component_name: str, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WebTestListResult"]: """Get all Application Insights web tests defined for the specified component. :param component_name: The name of the Application Insights component resource. @@ -446,7 +664,8 @@ def list_by_component( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebTestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_05_01_preview.models.WebTestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WebTestListResult"] @@ -454,36 +673,33 @@ def list_by_component( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_component.metadata['url'] # type: ignore - path_format_arguments = { - 'componentName': self._serialize.url("component_name", component_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_component.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WebTestListResult', pipeline_response) + deserialized = self._deserialize("WebTestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -501,6 +717,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py index 2b2f90ed5e23b..15cbc54dda34c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_application_insights_management_client.py @@ -6,78 +6,80 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import Operations, WorkbooksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import WorkbooksOperations -from .operations import Operations -from . import models - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations - :vartype workbooks: azure.mgmt.applicationinsights.v2018_06_17_preview.operations.WorkbooksOperations + :vartype workbooks: + azure.mgmt.applicationinsights.v2018_06_17_preview.operations.WorkbooksOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.applicationinsights.v2018_06_17_preview.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py index 7c84b057f86a8..5175ae2e638ff 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json index 454b45d1c3210..329db6d2b87f8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbooks": "WorkbooksOperations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py index 083f370d2cc44..32f21277a3ad7 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_application_insights_management_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import Operations, WorkbooksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import WorkbooksOperations -from .operations import Operations -from .. import models - - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations - :vartype workbooks: azure.mgmt.applicationinsights.v2018_06_17_preview.aio.operations.WorkbooksOperations + :vartype workbooks: + azure.mgmt.applicationinsights.v2018_06_17_preview.aio.operations.WorkbooksOperations :ivar operations: Operations operations - :vartype operations: azure.mgmt.applicationinsights.v2018_06_17_preview.aio.operations.Operations + :vartype operations: + azure.mgmt.applicationinsights.v2018_06_17_preview.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py index 1cbd3ee24f102..04285ba45009f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py index e6e947d27eec8..fd3eb71940331 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py index d319acc43cad6..3cb8ba1695280 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/aio/operations/_workbooks_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._workbooks_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -65,7 +71,8 @@ def list_by_resource_group( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbooksListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -73,41 +80,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + source_id=source_id, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + source_id=source_id, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,17 +125,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -153,33 +160,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -188,8 +185,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -212,33 +212,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -246,6 +236,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -274,39 +266,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'Workbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + source_id=source_id, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -319,8 +301,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -339,7 +324,8 @@ async def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. - :type workbook_update_parameters: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook @@ -350,42 +336,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if workbook_update_parameters is not None: - body_content = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') + _json = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + source_id=source_id, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -394,4 +370,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py index bd981aaaa1436..ac0d37e3232cf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py @@ -6,28 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorFieldContract - from ._models_py3 import ErrorResponse - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import Resource - from ._models_py3 import Workbook - from ._models_py3 import WorkbookError - from ._models_py3 import WorkbookUpdateParameters - from ._models_py3 import WorkbooksListResult -except (SyntaxError, ImportError): - from ._models import ErrorFieldContract # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import Resource # type: ignore - from ._models import Workbook # type: ignore - from ._models import WorkbookError # type: ignore - from ._models import WorkbookUpdateParameters # type: ignore - from ._models import WorkbooksListResult # type: ignore +from ._models_py3 import ErrorFieldContract +from ._models_py3 import ErrorResponse +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Resource +from ._models_py3 import Workbook +from ._models_py3 import WorkbookError +from ._models_py3 import WorkbookUpdateParameters +from ._models_py3 import WorkbooksListResult + from ._application_insights_management_client_enums import ( CategoryType, diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_application_insights_management_client_enums.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_application_insights_management_client_enums.py index 3b8d45be32b37..135c38c67cfe4 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_application_insights_management_client_enums.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_application_insights_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CategoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WORKBOOK = "workbook" TSG = "TSG" PERFORMANCE = "performance" RETENTION = "retention" -class SharedTypeKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SharedTypeKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of workbook. Choices are user and shared. """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models.py deleted file mode 100644 index 94fe5bfcfd841..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorFieldContract(msrest.serialization.Model): - """Error Field contract. - - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorFieldContract, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class Operation(msrest.serialization.Model): - """CDN REST API operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.Cdn. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - - -class OperationListResult(msrest.serialization.Model): - """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. - - :param value: List of CDN operations supported by the CDN resource provider. - :type value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. This is GUID value. The display name should be assigned within - properties field. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.kind = kwargs.get('kind', None) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class Workbook(Resource): - """An Application Insights workbook definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. This is GUID value. The display name should be assigned within - properties field. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a - string containing valid JSON. - :type serialized_data: str - :ivar time_modified: Date and time in UTC of the last modification that was made to this - workbook definition. - :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param version: Workbook version. - :type version: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook - definition. - :type tags_properties_tags: list[str] - :ivar user_id: Unique user id of the specific user that owns this workbook. - :vartype user_id: str - :param source_id: ResourceId for a source resource. - :type source_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'time_modified': {'readonly': True}, - 'user_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, - 'time_modified': {'key': 'properties.timeModified', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'tags_properties_tags': {'key': 'properties.tags', 'type': '[str]'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - 'source_id': {'key': 'properties.sourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Workbook, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.serialized_data = kwargs.get('serialized_data', None) - self.time_modified = None - self.category = kwargs.get('category', None) - self.version = kwargs.get('version', None) - self.tags_properties_tags = kwargs.get('tags_properties_tags', None) - self.user_id = None - self.source_id = kwargs.get('source_id', None) - - -class WorkbookError(msrest.serialization.Model): - """Error message body that will indicate why the operation failed. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: - list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.ErrorFieldContract] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class WorkbooksListResult(msrest.serialization.Model): - """Workbook list result. - - :param value: An array of workbooks. - :type value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Workbook]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbooksListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class WorkbookUpdateParameters(msrest.serialization.Model): - """The parameters that can be provided when updating workbook properties properties. - - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a - string containing valid JSON. - :type serialized_data: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook - definition. - :type tags_properties_tags: list[str] - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'tags_properties_tags': {'key': 'properties.tags', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookUpdateParameters, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.tags = kwargs.get('tags', None) - self.display_name = kwargs.get('display_name', None) - self.serialized_data = kwargs.get('serialized_data', None) - self.category = kwargs.get('category', None) - self.tags_properties_tags = kwargs.get('tags_properties_tags', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py index 1fc733b3d5ef2..b5bf9ef39c62a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/_models_py3.py @@ -17,12 +17,12 @@ class ErrorFieldContract(msrest.serialization.Model): """Error Field contract. - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str """ _attribute_map = { @@ -39,6 +39,14 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword code: Property level error code. + :paramtype code: str + :keyword message: Human-readable representation of property-level error. + :paramtype message: str + :keyword target: Property name. + :paramtype target: str + """ super(ErrorFieldContract, self).__init__(**kwargs) self.code = code self.message = message @@ -48,10 +56,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -66,6 +74,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -74,10 +88,10 @@ def __init__( class Operation(msrest.serialization.Model): """CDN REST API operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationDisplay """ _attribute_map = { @@ -92,6 +106,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -100,12 +120,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Cdn. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Cdn. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -122,6 +142,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Cdn. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -131,10 +159,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """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. - :param value: List of CDN operations supported by the CDN resource provider. - :type value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of CDN operations supported by the CDN resource provider. + :vartype value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -149,6 +177,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of CDN operations supported by the CDN resource provider. + :paramtype value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -168,13 +202,13 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -201,6 +235,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or + ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -224,32 +268,32 @@ class Workbook(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar display_name: The user-defined name (display name) of the workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a string containing valid JSON. - :type serialized_data: str + :vartype serialized_data: str :ivar time_modified: Date and time in UTC of the last modification that was made to this workbook definition. :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param version: Workbook version. - :type version: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar version: Workbook version. + :vartype version: str + :ivar tags_properties_tags: A list of 0 or more tags that are associated with this workbook definition. - :type tags_properties_tags: list[str] + :vartype tags_properties_tags: list[str] :ivar user_id: Unique user id of the specific user that owns this workbook. :vartype user_id: str - :param source_id: ResourceId for a source resource. - :type source_id: str + :ivar source_id: ResourceId for a source resource. + :vartype source_id: str """ _validation = { @@ -292,6 +336,30 @@ def __init__( source_id: Optional[str] = None, **kwargs ): + """ + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or + ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword display_name: The user-defined name (display name) of the workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword version: Workbook version. + :paramtype version: str + :keyword tags_properties_tags: A list of 0 or more tags that are associated with this workbook + definition. + :paramtype tags_properties_tags: list[str] + :keyword source_id: ResourceId for a source resource. + :paramtype source_id: str + """ super(Workbook, self).__init__(kind=kind, location=location, tags=tags, **kwargs) self.display_name = display_name self.serialized_data = serialized_data @@ -306,13 +374,13 @@ def __init__( class WorkbookError(msrest.serialization.Model): """Error message body that will indicate why the operation failed. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.ErrorFieldContract] """ @@ -330,6 +398,16 @@ def __init__( details: Optional[List["ErrorFieldContract"]] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: + list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.ErrorFieldContract] + """ super(WorkbookError, self).__init__(**kwargs) self.code = code self.message = message @@ -339,8 +417,8 @@ def __init__( class WorkbooksListResult(msrest.serialization.Model): """Workbook list result. - :param value: An array of workbooks. - :type value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook] + :ivar value: An array of workbooks. + :vartype value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook] """ _attribute_map = { @@ -353,6 +431,10 @@ def __init__( value: Optional[List["Workbook"]] = None, **kwargs ): + """ + :keyword value: An array of workbooks. + :paramtype value: list[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook] + """ super(WorkbooksListResult, self).__init__(**kwargs) self.value = value @@ -360,21 +442,21 @@ def __init__( class WorkbookUpdateParameters(msrest.serialization.Model): """The parameters that can be provided when updating workbook properties properties. - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar display_name: The user-defined name (display name) of the workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a string containing valid JSON. - :type serialized_data: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook + :vartype serialized_data: str + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: A list of 0 or more tags that are associated with this workbook definition. - :type tags_properties_tags: list[str] + :vartype tags_properties_tags: list[str] """ _attribute_map = { @@ -397,6 +479,24 @@ def __init__( tags_properties_tags: Optional[List[str]] = None, **kwargs ): + """ + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or + ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.SharedTypeKind + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword display_name: The user-defined name (display name) of the workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: A list of 0 or more tags that are associated with this workbook + definition. + :paramtype tags_properties_tags: list[str] + """ super(WorkbookUpdateParameters, self).__init__(**kwargs) self.kind = kind self.tags = tags diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py index b1c5f912d86df..f37ed3eddcfe1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Insights/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available insights REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py index b97e87e8fe77a..bec58b771cccf 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/operations/_workbooks_operations.py @@ -5,23 +5,232 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + category: Union[str, "_models.CategoryType"], + source_id: str, + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + source_id: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + source_id: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class WorkbooksOperations(object): """WorkbooksOperations operations. @@ -45,16 +254,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - category, # type: Union[str, "_models.CategoryType"] - source_id, # type: str - tags=None, # type: Optional[List[str]] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkbooksListResult"] + resource_group_name: str, + category: Union[str, "_models.CategoryType"], + source_id: str, + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.WorkbooksListResult"]: """Get all Workbooks defined within a specified resource group and category. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,7 +279,8 @@ def list_by_resource_group( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbooksListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -78,41 +288,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + source_id=source_id, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + source_id=source_id, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,24 +333,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.Workbook": """Get a single workbook by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -159,33 +368,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -194,15 +393,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Delete a workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -219,33 +420,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -253,15 +444,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - source_id, # type: str - workbook_properties, # type: "_models.Workbook" - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + source_id: str, + workbook_properties: "_models.Workbook", + **kwargs: Any + ) -> "_models.Workbook": """Create a new workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -282,39 +474,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'Workbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + source_id=source_id, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -327,17 +509,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - source_id, # type: str - workbook_update_parameters=None, # type: Optional["_models.WorkbookUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + source_id: str, + workbook_update_parameters: Optional["_models.WorkbookUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.Workbook": """Updates a workbook that has already been added. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -348,7 +532,8 @@ def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. - :type workbook_update_parameters: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.WorkbookUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2018_06_17_preview.models.Workbook @@ -359,42 +544,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if workbook_update_parameters is not None: - body_content = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') + _json = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + source_id=source_id, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -403,4 +578,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py index ff2c8bf675cd8..7a36ea548bf8e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_application_insights_management_client.py @@ -6,73 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import WorkbookTemplatesOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations - :vartype workbook_templates: azure.mgmt.applicationinsights.v2019_10_17_preview.operations.WorkbookTemplatesOperations + :vartype workbook_templates: + azure.mgmt.applicationinsights.v2019_10_17_preview.operations.WorkbookTemplatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbook_templates = WorkbookTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py index cbde4101bb273..28bd0dc39bedd 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json index fbdf6105e05f1..ffd2c95829bf8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbook_templates": "WorkbookTemplatesOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py index dc3c181c4e720..6e6ef233aadd2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_application_insights_management_client.py @@ -6,69 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import WorkbookTemplatesOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations - :vartype workbook_templates: azure.mgmt.applicationinsights.v2019_10_17_preview.aio.operations.WorkbookTemplatesOperations + :vartype workbook_templates: + azure.mgmt.applicationinsights.v2019_10_17_preview.aio.operations.WorkbookTemplatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbook_templates = WorkbookTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py index 8c397863cc0e1..6dc606d6a599f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py index 00a55e8b0c017..d152f945ca73b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/aio/operations/_workbook_templates_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._workbook_templates_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -51,8 +57,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkbookTemplatesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplatesListResult] + :return: An iterator like instance of either WorkbookTemplatesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplatesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbookTemplatesListResult"] @@ -60,35 +68,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbookTemplatesListResult', pipeline_response) + deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +105,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -134,33 +140,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -169,8 +165,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -193,33 +192,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +216,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -242,7 +233,8 @@ async def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. - :type workbook_template_properties: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate + :type workbook_template_properties: + ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate @@ -253,38 +245,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -297,8 +279,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -314,7 +299,8 @@ async def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. - :type workbook_template_update_parameters: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateUpdateParameters + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate @@ -325,41 +311,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if workbook_template_update_parameters is not None: - body_content = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') + _json = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -368,4 +344,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py index b3b5566499ae2..ca5fa20f23470 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/__init__.py @@ -6,24 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorFieldContract - from ._models_py3 import WorkbookError - from ._models_py3 import WorkbookTemplate - from ._models_py3 import WorkbookTemplateGallery - from ._models_py3 import WorkbookTemplateLocalizedGallery - from ._models_py3 import WorkbookTemplateResource - from ._models_py3 import WorkbookTemplateUpdateParameters - from ._models_py3 import WorkbookTemplatesListResult -except (SyntaxError, ImportError): - from ._models import ErrorFieldContract # type: ignore - from ._models import WorkbookError # type: ignore - from ._models import WorkbookTemplate # type: ignore - from ._models import WorkbookTemplateGallery # type: ignore - from ._models import WorkbookTemplateLocalizedGallery # type: ignore - from ._models import WorkbookTemplateResource # type: ignore - from ._models import WorkbookTemplateUpdateParameters # type: ignore - from ._models import WorkbookTemplatesListResult # type: ignore +from ._models_py3 import ErrorFieldContract +from ._models_py3 import WorkbookError +from ._models_py3 import WorkbookTemplate +from ._models_py3 import WorkbookTemplateGallery +from ._models_py3 import WorkbookTemplateLocalizedGallery +from ._models_py3 import WorkbookTemplateResource +from ._models_py3 import WorkbookTemplateUpdateParameters +from ._models_py3 import WorkbookTemplatesListResult + __all__ = [ 'ErrorFieldContract', diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models.py deleted file mode 100644 index d7474711cdd95..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models.py +++ /dev/null @@ -1,298 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorFieldContract(msrest.serialization.Model): - """Error Field contract. - - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorFieldContract, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - - -class WorkbookError(msrest.serialization.Model): - """Error message body that will indicate why the operation failed. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: - list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.ErrorFieldContract] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class WorkbookTemplateResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class WorkbookTemplate(WorkbookTemplateResource): - """An Application Insights workbook template definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook - gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: - list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages - supported by the Azure portal. - :type localized: dict[str, - list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateLocalizedGallery]] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'priority': {'key': 'properties.priority', 'type': 'int'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'template_data': {'key': 'properties.templateData', 'type': 'object'}, - 'galleries': {'key': 'properties.galleries', 'type': '[WorkbookTemplateGallery]'}, - 'localized': {'key': 'properties.localized', 'type': '{[WorkbookTemplateLocalizedGallery]}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplate, self).__init__(**kwargs) - self.priority = kwargs.get('priority', None) - self.author = kwargs.get('author', None) - self.template_data = kwargs.get('template_data', None) - self.galleries = kwargs.get('galleries', None) - self.localized = kwargs.get('localized', None) - - -class WorkbookTemplateGallery(msrest.serialization.Model): - """Gallery information for a workbook template. - - :param name: Name of the workbook template in the gallery. - :type name: str - :param category: Category for the gallery. - :type category: str - :param type: Type of workbook supported by the workbook template. - :type type: str - :param order: Order of the template within the gallery. - :type order: int - :param resource_type: Azure resource type supported by the gallery. - :type resource_type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'order': {'key': 'order', 'type': 'int'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateGallery, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.category = kwargs.get('category', None) - self.type = kwargs.get('type', None) - self.order = kwargs.get('order', None) - self.resource_type = kwargs.get('resource_type', None) - - -class WorkbookTemplateLocalizedGallery(msrest.serialization.Model): - """Localized template data and gallery information. - - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: - list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] - """ - - _attribute_map = { - 'template_data': {'key': 'templateData', 'type': 'object'}, - 'galleries': {'key': 'galleries', 'type': '[WorkbookTemplateGallery]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateLocalizedGallery, self).__init__(**kwargs) - self.template_data = kwargs.get('template_data', None) - self.galleries = kwargs.get('galleries', None) - - -class WorkbookTemplatesListResult(msrest.serialization.Model): - """WorkbookTemplate list result. - - :param value: An array of workbook templates. - :type value: list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkbookTemplate]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplatesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class WorkbookTemplateUpdateParameters(msrest.serialization.Model): - """The parameters that can be provided when updating workbook template. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook - gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: - list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages - supported by the Azure portal. - :type localized: dict[str, - list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateLocalizedGallery]] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'priority': {'key': 'properties.priority', 'type': 'int'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'template_data': {'key': 'properties.templateData', 'type': 'object'}, - 'galleries': {'key': 'properties.galleries', 'type': '[WorkbookTemplateGallery]'}, - 'localized': {'key': 'properties.localized', 'type': '{[WorkbookTemplateLocalizedGallery]}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.priority = kwargs.get('priority', None) - self.author = kwargs.get('author', None) - self.template_data = kwargs.get('template_data', None) - self.galleries = kwargs.get('galleries', None) - self.localized = kwargs.get('localized', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py index 8dbba4f14bc83..fccf4cbe4e44e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/models/_models_py3.py @@ -15,12 +15,12 @@ class ErrorFieldContract(msrest.serialization.Model): """Error Field contract. - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str """ _attribute_map = { @@ -37,6 +37,14 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword code: Property level error code. + :paramtype code: str + :keyword message: Human-readable representation of property-level error. + :paramtype message: str + :keyword target: Property name. + :paramtype target: str + """ super(ErrorFieldContract, self).__init__(**kwargs) self.code = code self.message = message @@ -46,13 +54,13 @@ def __init__( class WorkbookError(msrest.serialization.Model): """Error message body that will indicate why the operation failed. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.ErrorFieldContract] """ @@ -70,6 +78,16 @@ def __init__( details: Optional[List["ErrorFieldContract"]] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.ErrorFieldContract] + """ super(WorkbookError, self).__init__(**kwargs) self.code = code self.message = message @@ -89,10 +107,10 @@ class WorkbookTemplateResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -117,6 +135,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(WorkbookTemplateResource, self).__init__(**kwargs) self.id = None self.name = None @@ -138,23 +162,23 @@ class WorkbookTemplate(WorkbookTemplateResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar priority: Priority of the template. Determines which template to open when a workbook gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: + :vartype priority: int + :ivar author: Information about the author of the workbook template. + :vartype author: str + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: any + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages + :ivar localized: Key value pair of localized gallery. Each key is the locale code of languages supported by the Azure portal. - :type localized: dict[str, + :vartype localized: dict[str, list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateLocalizedGallery]] """ @@ -190,6 +214,26 @@ def __init__( localized: Optional[Dict[str, List["WorkbookTemplateLocalizedGallery"]]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :paramtype priority: int + :keyword author: Information about the author of the workbook template. + :paramtype author: str + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: any + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] + :keyword localized: Key value pair of localized gallery. Each key is the locale code of + languages supported by the Azure portal. + :paramtype localized: dict[str, + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateLocalizedGallery]] + """ super(WorkbookTemplate, self).__init__(location=location, tags=tags, **kwargs) self.priority = priority self.author = author @@ -201,16 +245,16 @@ def __init__( class WorkbookTemplateGallery(msrest.serialization.Model): """Gallery information for a workbook template. - :param name: Name of the workbook template in the gallery. - :type name: str - :param category: Category for the gallery. - :type category: str - :param type: Type of workbook supported by the workbook template. - :type type: str - :param order: Order of the template within the gallery. - :type order: int - :param resource_type: Azure resource type supported by the gallery. - :type resource_type: str + :ivar name: Name of the workbook template in the gallery. + :vartype name: str + :ivar category: Category for the gallery. + :vartype category: str + :ivar type: Type of workbook supported by the workbook template. + :vartype type: str + :ivar order: Order of the template within the gallery. + :vartype order: int + :ivar resource_type: Azure resource type supported by the gallery. + :vartype resource_type: str """ _attribute_map = { @@ -231,6 +275,18 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the workbook template in the gallery. + :paramtype name: str + :keyword category: Category for the gallery. + :paramtype category: str + :keyword type: Type of workbook supported by the workbook template. + :paramtype type: str + :keyword order: Order of the template within the gallery. + :paramtype order: int + :keyword resource_type: Azure resource type supported by the gallery. + :paramtype resource_type: str + """ super(WorkbookTemplateGallery, self).__init__(**kwargs) self.name = name self.category = category @@ -242,10 +298,10 @@ def __init__( class WorkbookTemplateLocalizedGallery(msrest.serialization.Model): """Localized template data and gallery information. - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: any + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] """ @@ -261,6 +317,13 @@ def __init__( galleries: Optional[List["WorkbookTemplateGallery"]] = None, **kwargs ): + """ + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: any + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] + """ super(WorkbookTemplateLocalizedGallery, self).__init__(**kwargs) self.template_data = template_data self.galleries = galleries @@ -269,8 +332,9 @@ def __init__( class WorkbookTemplatesListResult(msrest.serialization.Model): """WorkbookTemplate list result. - :param value: An array of workbook templates. - :type value: list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate] + :ivar value: An array of workbook templates. + :vartype value: + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate] """ _attribute_map = { @@ -283,6 +347,11 @@ def __init__( value: Optional[List["WorkbookTemplate"]] = None, **kwargs ): + """ + :keyword value: An array of workbook templates. + :paramtype value: + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate] + """ super(WorkbookTemplatesListResult, self).__init__(**kwargs) self.value = value @@ -290,21 +359,21 @@ def __init__( class WorkbookTemplateUpdateParameters(msrest.serialization.Model): """The parameters that can be provided when updating workbook template. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar priority: Priority of the template. Determines which template to open when a workbook gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: + :vartype priority: int + :ivar author: Information about the author of the workbook template. + :vartype author: str + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: any + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages + :ivar localized: Key value pair of localized gallery. Each key is the locale code of languages supported by the Azure portal. - :type localized: dict[str, + :vartype localized: dict[str, list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateLocalizedGallery]] """ @@ -328,6 +397,24 @@ def __init__( localized: Optional[Dict[str, List["WorkbookTemplateLocalizedGallery"]]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :paramtype priority: int + :keyword author: Information about the author of the workbook template. + :paramtype author: str + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: any + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateGallery] + :keyword localized: Key value pair of localized gallery. Each key is the locale code of + languages supported by the Azure portal. + :paramtype localized: dict[str, + list[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateLocalizedGallery]] + """ super(WorkbookTemplateUpdateParameters, self).__init__(**kwargs) self.tags = tags self.priority = priority diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py index e606999cb323e..521dd873137fa 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2019_10_17_preview/operations/_workbook_templates_operations.py @@ -5,23 +5,217 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class WorkbookTemplatesOperations(object): """WorkbookTemplatesOperations operations. @@ -45,19 +239,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkbookTemplatesListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkbookTemplatesListResult"]: """Get all Workbook templates defined within a specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkbookTemplatesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplatesListResult] + :return: An iterator like instance of either WorkbookTemplatesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplatesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbookTemplatesListResult"] @@ -65,35 +261,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbookTemplatesListResult', pipeline_response) + deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,24 +298,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkbookTemplate" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.WorkbookTemplate": """Get a single workbook template by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -140,33 +333,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -175,15 +358,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Delete a workbook template. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -200,33 +385,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,14 +409,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_template_properties, # type: "_models.WorkbookTemplate" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkbookTemplate" + resource_group_name: str, + resource_name: str, + workbook_template_properties: "_models.WorkbookTemplate", + **kwargs: Any + ) -> "_models.WorkbookTemplate": """Create a new workbook template. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -250,7 +426,8 @@ def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. - :type workbook_template_properties: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate + :type workbook_template_properties: + ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate @@ -261,38 +438,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -305,16 +472,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_template_update_parameters=None, # type: Optional["_models.WorkbookTemplateUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkbookTemplate" + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional["_models.WorkbookTemplateUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.WorkbookTemplate": """Updates a workbook template that has already been added. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -323,7 +492,8 @@ def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. - :type workbook_template_update_parameters: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateUpdateParameters + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2019_10_17_preview.models.WorkbookTemplate @@ -334,41 +504,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if workbook_template_update_parameters is not None: - body_content = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') + _json = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -377,4 +537,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooktemplates/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py index c8af7cbbfdae4..459281a62de15 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_application_insights_management_client.py @@ -6,73 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import ComponentsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar components: ComponentsOperations operations - :vartype components: azure.mgmt.applicationinsights.v2020_02_02_preview.operations.ComponentsOperations + :vartype components: + azure.mgmt.applicationinsights.v2020_02_02_preview.operations.ComponentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.components = ComponentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py index ebb837b275501..5fe0fbecfca4f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json index 1a591cd50bb18..88ccae4e8bfa2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "components": "ComponentsOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py index c3ba0355c5805..4825272e2d22b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_application_insights_management_client.py @@ -6,69 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import ComponentsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar components: ComponentsOperations operations - :vartype components: azure.mgmt.applicationinsights.v2020_02_02_preview.aio.operations.ComponentsOperations + :vartype components: + azure.mgmt.applicationinsights.v2020_02_02_preview.aio.operations.ComponentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.components = ComponentsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py index 321996a019dd1..b27146565f471 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py index 29e7c25d41e97..5253120b2b5db 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/aio/operations/_components_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._components_operations import build_create_or_update_request, build_delete_request, build_get_purge_status_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_purge_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """Gets a list of all Application Insights components within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +100,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -118,8 +123,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -127,35 +134,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,17 +171,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -201,33 +206,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -235,6 +230,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -257,33 +254,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplicationInsightsComponent', pipeline_response) @@ -292,8 +279,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -310,7 +300,8 @@ async def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. - :type insight_properties: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent + :type insight_properties: + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent @@ -321,38 +312,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplicationInsightsComponent', pipeline_response) @@ -361,8 +342,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, @@ -388,38 +372,28 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(component_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(component_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplicationInsightsComponent', pipeline_response) @@ -428,8 +402,11 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace_async async def purge( self, resource_group_name: str, @@ -462,38 +439,28 @@ async def purge( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.purge.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ComponentPurgeBody') + + request = build_purge_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.purge.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ComponentPurgeBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentPurgeResponse', pipeline_response) @@ -502,8 +469,11 @@ async def purge( return cls(pipeline_response, deserialized, {}) return deserialized + purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'} # type: ignore + + @distributed_trace_async async def get_purge_status( self, resource_group_name: str, @@ -530,34 +500,24 @@ async def get_purge_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - - # Construct URL - url = self.get_purge_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'purgeId': self._serialize.url("purge_id", purge_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_purge_status_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + purge_id=purge_id, + template_url=self.get_purge_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentPurgeStatusResponse', pipeline_response) @@ -566,4 +526,6 @@ async def get_purge_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py index 9d810722c16df..7d0a42ffd435c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/__init__.py @@ -6,32 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApplicationInsightsComponent - from ._models_py3 import ApplicationInsightsComponentListResult - from ._models_py3 import ComponentPurgeBody - from ._models_py3 import ComponentPurgeBodyFilters - from ._models_py3 import ComponentPurgeResponse - from ._models_py3 import ComponentPurgeStatusResponse - from ._models_py3 import ComponentsResource - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import PrivateLinkScopedResource - from ._models_py3 import TagsResource -except (SyntaxError, ImportError): - from ._models import ApplicationInsightsComponent # type: ignore - from ._models import ApplicationInsightsComponentListResult # type: ignore - from ._models import ComponentPurgeBody # type: ignore - from ._models import ComponentPurgeBodyFilters # type: ignore - from ._models import ComponentPurgeResponse # type: ignore - from ._models import ComponentPurgeStatusResponse # type: ignore - from ._models import ComponentsResource # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import PrivateLinkScopedResource # type: ignore - from ._models import TagsResource # type: ignore +from ._models_py3 import ApplicationInsightsComponent +from ._models_py3 import ApplicationInsightsComponentListResult +from ._models_py3 import ComponentPurgeBody +from ._models_py3 import ComponentPurgeBodyFilters +from ._models_py3 import ComponentPurgeResponse +from ._models_py3 import ComponentPurgeStatusResponse +from ._models_py3 import ComponentsResource +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import PrivateLinkScopedResource +from ._models_py3 import TagsResource + from ._application_insights_management_client_enums import ( ApplicationType, diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_application_insights_management_client_enums.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_application_insights_management_client_enums.py index 520c2acfc8241..1026b550e7f0d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_application_insights_management_client_enums.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_application_insights_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ApplicationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApplicationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of application being monitored. """ WEB = "web" OTHER = "other" -class FlowType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FlowType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. @@ -41,7 +26,7 @@ class FlowType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BLUEFIELD = "Bluefield" -class IngestionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IngestionMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the flow of the ingestion. """ @@ -49,7 +34,7 @@ class IngestionMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPLICATION_INSIGHTS_WITH_DIAGNOSTIC_SETTINGS = "ApplicationInsightsWithDiagnosticSettings" LOG_ANALYTICS = "LogAnalytics" -class PublicNetworkAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The network access type for operating on the Application Insights Component. By default it is Enabled """ @@ -59,14 +44,14 @@ class PublicNetworkAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum #: Disables public connectivity to Application Insights through public DNS. DISABLED = "Disabled" -class PurgeState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PurgeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the operation represented by the requested Id. """ PENDING = "pending" COMPLETED = "completed" -class RequestSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RequestSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models.py deleted file mode 100644 index 02e7e8b9db936..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models.py +++ /dev/null @@ -1,534 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ComponentsResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentsResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ApplicationInsightsComponent(ComponentsResource): - """An Application Insights component definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. The kind of application that this component refers to, used to customize - UI. This value is a freeform string, values should typically be one of the following: web, ios, - other, store, java, phone. - :type kind: str - :param etag: Resource etag. - :type etag: str - :ivar application_id: The unique ID of your application. This field mirrors the 'Name' field - and cannot be changed. - :vartype application_id: str - :ivar app_id: Application Insights Unique ID for your Application. - :vartype app_id: str - :ivar name_properties_name: Application name. - :vartype name_properties_name: str - :param application_type: Type of application being monitored. Possible values include: "web", - "other". Default value: "web". - :type application_type: str or - ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationType - :param flow_type: Used by the Application Insights system to determine what kind of flow this - component was created by. This is to be set to 'Bluefield' when creating/updating a component - via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". - :type flow_type: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.FlowType - :param request_source: Describes what tool created this Application Insights component. - Customers using this API should set this to the default 'rest'. Possible values include: - "rest". Default value: "rest". - :type request_source: str or - ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.RequestSource - :ivar instrumentation_key: Application Insights Instrumentation key. A read-only value that - applications can use to identify the destination for all telemetry sent to Azure Application - Insights. This value will be supplied upon construction of each new Application Insights - component. - :vartype instrumentation_key: str - :ivar creation_date: Creation Date for the Application Insights component, in ISO 8601 format. - :vartype creation_date: ~datetime.datetime - :ivar tenant_id: Azure Tenant Id. - :vartype tenant_id: str - :param hockey_app_id: The unique application ID created when a new application is added to - HockeyApp, used for communications with HockeyApp. - :type hockey_app_id: str - :ivar hockey_app_token: Token used to authenticate communications with between Application - Insights and HockeyApp. - :vartype hockey_app_token: str - :ivar provisioning_state: Current state of this component: whether or not is has been - provisioned within the resource group it is defined. Users cannot change this value but are - able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. - :vartype provisioning_state: str - :param sampling_percentage: Percentage of the data produced by the application being monitored - that is being sampled for Application Insights telemetry. - :type sampling_percentage: float - :ivar connection_string: Application Insights component connection string. - :vartype connection_string: str - :ivar retention_in_days: Retention period in days. - :vartype retention_in_days: int - :param disable_ip_masking: Disable IP masking. - :type disable_ip_masking: bool - :param immediate_purge_data_on30_days: Purge data immediately after 30 days. - :type immediate_purge_data_on30_days: bool - :param workspace_resource_id: Resource Id of the log analytics workspace which the data will be - ingested to. This property is required to create an application with this API version. - Applications from older versions will not have this property. - :type workspace_resource_id: str - :ivar la_migration_date: The date which the component got migrated to LA, in ISO 8601 format. - :vartype la_migration_date: ~datetime.datetime - :ivar private_link_scoped_resources: List of linked private link scope resources. - :vartype private_link_scoped_resources: - list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PrivateLinkScopedResource] - :param public_network_access_for_ingestion: The network access type for accessing Application - Insights ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_ingestion: str or - ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PublicNetworkAccessType - :param public_network_access_for_query: The network access type for accessing Application - Insights query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_query: str or - ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PublicNetworkAccessType - :param ingestion_mode: Indicates the flow of the ingestion. Possible values include: - "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default - value: "LogAnalytics". - :type ingestion_mode: str or - ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.IngestionMode - :param disable_local_auth: Disable Non-AAD based Auth. - :type disable_local_auth: bool - :param force_customer_storage_for_profiler: Force users to create their own storage account for - profiler and debugger. - :type force_customer_storage_for_profiler: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'required': True}, - 'application_id': {'readonly': True}, - 'app_id': {'readonly': True}, - 'name_properties_name': {'readonly': True}, - 'instrumentation_key': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'hockey_app_token': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'connection_string': {'readonly': True}, - 'retention_in_days': {'readonly': True}, - 'la_migration_date': {'readonly': True}, - 'private_link_scoped_resources': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'application_id': {'key': 'properties.ApplicationId', 'type': 'str'}, - 'app_id': {'key': 'properties.AppId', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.Name', 'type': 'str'}, - 'application_type': {'key': 'properties.Application_Type', 'type': 'str'}, - 'flow_type': {'key': 'properties.Flow_Type', 'type': 'str'}, - 'request_source': {'key': 'properties.Request_Source', 'type': 'str'}, - 'instrumentation_key': {'key': 'properties.InstrumentationKey', 'type': 'str'}, - 'creation_date': {'key': 'properties.CreationDate', 'type': 'iso-8601'}, - 'tenant_id': {'key': 'properties.TenantId', 'type': 'str'}, - 'hockey_app_id': {'key': 'properties.HockeyAppId', 'type': 'str'}, - 'hockey_app_token': {'key': 'properties.HockeyAppToken', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sampling_percentage': {'key': 'properties.SamplingPercentage', 'type': 'float'}, - 'connection_string': {'key': 'properties.ConnectionString', 'type': 'str'}, - 'retention_in_days': {'key': 'properties.RetentionInDays', 'type': 'int'}, - 'disable_ip_masking': {'key': 'properties.DisableIpMasking', 'type': 'bool'}, - 'immediate_purge_data_on30_days': {'key': 'properties.ImmediatePurgeDataOn30Days', 'type': 'bool'}, - 'workspace_resource_id': {'key': 'properties.WorkspaceResourceId', 'type': 'str'}, - 'la_migration_date': {'key': 'properties.LaMigrationDate', 'type': 'iso-8601'}, - 'private_link_scoped_resources': {'key': 'properties.PrivateLinkScopedResources', 'type': '[PrivateLinkScopedResource]'}, - 'public_network_access_for_ingestion': {'key': 'properties.publicNetworkAccessForIngestion', 'type': 'str'}, - 'public_network_access_for_query': {'key': 'properties.publicNetworkAccessForQuery', 'type': 'str'}, - 'ingestion_mode': {'key': 'properties.IngestionMode', 'type': 'str'}, - 'disable_local_auth': {'key': 'properties.DisableLocalAuth', 'type': 'bool'}, - 'force_customer_storage_for_profiler': {'key': 'properties.ForceCustomerStorageForProfiler', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponent, self).__init__(**kwargs) - self.kind = kwargs['kind'] - self.etag = kwargs.get('etag', None) - self.application_id = None - self.app_id = None - self.name_properties_name = None - self.application_type = kwargs.get('application_type', "web") - self.flow_type = kwargs.get('flow_type', "Bluefield") - self.request_source = kwargs.get('request_source', "rest") - self.instrumentation_key = None - self.creation_date = None - self.tenant_id = None - self.hockey_app_id = kwargs.get('hockey_app_id', None) - self.hockey_app_token = None - self.provisioning_state = None - self.sampling_percentage = kwargs.get('sampling_percentage', None) - self.connection_string = None - self.retention_in_days = None - self.disable_ip_masking = kwargs.get('disable_ip_masking', None) - self.immediate_purge_data_on30_days = kwargs.get('immediate_purge_data_on30_days', None) - self.workspace_resource_id = kwargs.get('workspace_resource_id', None) - self.la_migration_date = None - self.private_link_scoped_resources = None - self.public_network_access_for_ingestion = kwargs.get('public_network_access_for_ingestion', "Enabled") - self.public_network_access_for_query = kwargs.get('public_network_access_for_query', "Enabled") - self.ingestion_mode = kwargs.get('ingestion_mode', "LogAnalytics") - self.disable_local_auth = kwargs.get('disable_local_auth', None) - self.force_customer_storage_for_profiler = kwargs.get('force_customer_storage_for_profiler', None) - - -class ApplicationInsightsComponentListResult(msrest.serialization.Model): - """Describes the list of Application Insights Resources. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of Application Insights component definitions. - :type value: - list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent] - :param next_link: The URI to get the next set of Application Insights component definitions if - too many components where returned in the result set. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplicationInsightsComponent]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationInsightsComponentListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class ComponentPurgeBody(msrest.serialization.Model): - """Describes the body of a purge request for an App Insights component. - - All required parameters must be populated in order to send to Azure. - - :param table: Required. Table from which to purge data. - :type table: str - :param filters: Required. The set of columns and filters (queries) to run over them to purge - the resulting data. - :type filters: - list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeBodyFilters] - """ - - _validation = { - 'table': {'required': True}, - 'filters': {'required': True}, - } - - _attribute_map = { - 'table': {'key': 'table', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': '[ComponentPurgeBodyFilters]'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeBody, self).__init__(**kwargs) - self.table = kwargs['table'] - self.filters = kwargs['filters'] - - -class ComponentPurgeBodyFilters(msrest.serialization.Model): - """User-defined filters to return data which will be purged from the table. - - :param column: The column of the table over which the given query should run. - :type column: str - :param operator: A query operator to evaluate over the provided column and value(s). Supported - operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would - in a KQL query. - :type operator: str - :param value: the value for the operator to function over. This can be a number (e.g., > 100), - a string (timestamp >= '2017-09-01') or array of values. - :type value: any - :param key: When filtering over custom dimensions, this key will be used as the name of the - custom dimension. - :type key: str - """ - - _attribute_map = { - 'column': {'key': 'column', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'object'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeBodyFilters, self).__init__(**kwargs) - self.column = kwargs.get('column', None) - self.operator = kwargs.get('operator', None) - self.value = kwargs.get('value', None) - self.key = kwargs.get('key', None) - - -class ComponentPurgeResponse(msrest.serialization.Model): - """Response containing operationId for a specific purge action. - - All required parameters must be populated in order to send to Azure. - - :param operation_id: Required. Id to use when querying for status for a particular purge - operation. - :type operation_id: str - """ - - _validation = { - 'operation_id': {'required': True}, - } - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeResponse, self).__init__(**kwargs) - self.operation_id = kwargs['operation_id'] - - -class ComponentPurgeStatusResponse(msrest.serialization.Model): - """Response containing status for a specific purge operation. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the operation represented by the requested Id. Possible - values include: "pending", "completed". - :type status: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PurgeState - """ - - _validation = { - 'status': {'required': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentPurgeStatusResponse, self).__init__(**kwargs) - self.status = kwargs['status'] - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class PrivateLinkScopedResource(msrest.serialization.Model): - """The private link scope resource reference. - - :param resource_id: The full resource Id of the private link scope resource. - :type resource_id: str - :param scope_id: The private link scope unique Identifier. - :type scope_id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'ResourceId', 'type': 'str'}, - 'scope_id': {'key': 'ScopeId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkScopedResource, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.scope_id = kwargs.get('scope_id', None) - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on a WebTest instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py index ea61fc745e58e..d4f6b046b9673 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/models/_models_py3.py @@ -27,10 +27,10 @@ class ComponentsResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -55,6 +55,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ComponentsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -76,16 +82,16 @@ class ApplicationInsightsComponent(ComponentsResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. The kind of application that this component refers to, used to customize + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone. - :type kind: str - :param etag: Resource etag. - :type etag: str + :vartype kind: str + :ivar etag: Resource etag. + :vartype etag: str :ivar application_id: The unique ID of your application. This field mirrors the 'Name' field and cannot be changed. :vartype application_id: str @@ -93,18 +99,18 @@ class ApplicationInsightsComponent(ComponentsResource): :vartype app_id: str :ivar name_properties_name: Application name. :vartype name_properties_name: str - :param application_type: Type of application being monitored. Possible values include: "web", + :ivar application_type: Type of application being monitored. Possible values include: "web", "other". Default value: "web". - :type application_type: str or + :vartype application_type: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationType - :param flow_type: Used by the Application Insights system to determine what kind of flow this + :ivar flow_type: Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". - :type flow_type: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.FlowType - :param request_source: Describes what tool created this Application Insights component. + :vartype flow_type: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.FlowType + :ivar request_source: Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. Possible values include: "rest". Default value: "rest". - :type request_source: str or + :vartype request_source: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.RequestSource :ivar instrumentation_key: Application Insights Instrumentation key. A read-only value that applications can use to identify the destination for all telemetry sent to Azure Application @@ -115,9 +121,9 @@ class ApplicationInsightsComponent(ComponentsResource): :vartype creation_date: ~datetime.datetime :ivar tenant_id: Azure Tenant Id. :vartype tenant_id: str - :param hockey_app_id: The unique application ID created when a new application is added to + :ivar hockey_app_id: The unique application ID created when a new application is added to HockeyApp, used for communications with HockeyApp. - :type hockey_app_id: str + :vartype hockey_app_id: str :ivar hockey_app_token: Token used to authenticate communications with between Application Insights and HockeyApp. :vartype hockey_app_token: str @@ -125,44 +131,44 @@ class ApplicationInsightsComponent(ComponentsResource): provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. :vartype provisioning_state: str - :param sampling_percentage: Percentage of the data produced by the application being monitored + :ivar sampling_percentage: Percentage of the data produced by the application being monitored that is being sampled for Application Insights telemetry. - :type sampling_percentage: float + :vartype sampling_percentage: float :ivar connection_string: Application Insights component connection string. :vartype connection_string: str :ivar retention_in_days: Retention period in days. :vartype retention_in_days: int - :param disable_ip_masking: Disable IP masking. - :type disable_ip_masking: bool - :param immediate_purge_data_on30_days: Purge data immediately after 30 days. - :type immediate_purge_data_on30_days: bool - :param workspace_resource_id: Resource Id of the log analytics workspace which the data will be + :ivar disable_ip_masking: Disable IP masking. + :vartype disable_ip_masking: bool + :ivar immediate_purge_data_on30_days: Purge data immediately after 30 days. + :vartype immediate_purge_data_on30_days: bool + :ivar workspace_resource_id: Resource Id of the log analytics workspace which the data will be ingested to. This property is required to create an application with this API version. Applications from older versions will not have this property. - :type workspace_resource_id: str + :vartype workspace_resource_id: str :ivar la_migration_date: The date which the component got migrated to LA, in ISO 8601 format. :vartype la_migration_date: ~datetime.datetime :ivar private_link_scoped_resources: List of linked private link scope resources. :vartype private_link_scoped_resources: list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PrivateLinkScopedResource] - :param public_network_access_for_ingestion: The network access type for accessing Application + :ivar public_network_access_for_ingestion: The network access type for accessing Application Insights ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_ingestion: str or + :vartype public_network_access_for_ingestion: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PublicNetworkAccessType - :param public_network_access_for_query: The network access type for accessing Application + :ivar public_network_access_for_query: The network access type for accessing Application Insights query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access_for_query: str or + :vartype public_network_access_for_query: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PublicNetworkAccessType - :param ingestion_mode: Indicates the flow of the ingestion. Possible values include: + :ivar ingestion_mode: Indicates the flow of the ingestion. Possible values include: "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default value: "LogAnalytics". - :type ingestion_mode: str or + :vartype ingestion_mode: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.IngestionMode - :param disable_local_auth: Disable Non-AAD based Auth. - :type disable_local_auth: bool - :param force_customer_storage_for_profiler: Force users to create their own storage account for + :ivar disable_local_auth: Disable Non-AAD based Auth. + :vartype disable_local_auth: bool + :ivar force_customer_storage_for_profiler: Force users to create their own storage account for profiler and debugger. - :type force_customer_storage_for_profiler: bool + :vartype force_customer_storage_for_profiler: bool """ _validation = { @@ -242,6 +248,64 @@ def __init__( force_customer_storage_for_profiler: Optional[bool] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Required. The kind of application that this component refers to, used to + customize UI. This value is a freeform string, values should typically be one of the following: + web, ios, other, store, java, phone. + :paramtype kind: str + :keyword etag: Resource etag. + :paramtype etag: str + :keyword application_type: Type of application being monitored. Possible values include: "web", + "other". Default value: "web". + :paramtype application_type: str or + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationType + :keyword flow_type: Used by the Application Insights system to determine what kind of flow this + component was created by. This is to be set to 'Bluefield' when creating/updating a component + via the REST API. Possible values include: "Bluefield". Default value: "Bluefield". + :paramtype flow_type: str or + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.FlowType + :keyword request_source: Describes what tool created this Application Insights component. + Customers using this API should set this to the default 'rest'. Possible values include: + "rest". Default value: "rest". + :paramtype request_source: str or + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.RequestSource + :keyword hockey_app_id: The unique application ID created when a new application is added to + HockeyApp, used for communications with HockeyApp. + :paramtype hockey_app_id: str + :keyword sampling_percentage: Percentage of the data produced by the application being + monitored that is being sampled for Application Insights telemetry. + :paramtype sampling_percentage: float + :keyword disable_ip_masking: Disable IP masking. + :paramtype disable_ip_masking: bool + :keyword immediate_purge_data_on30_days: Purge data immediately after 30 days. + :paramtype immediate_purge_data_on30_days: bool + :keyword workspace_resource_id: Resource Id of the log analytics workspace which the data will + be ingested to. This property is required to create an application with this API version. + Applications from older versions will not have this property. + :paramtype workspace_resource_id: str + :keyword public_network_access_for_ingestion: The network access type for accessing Application + Insights ingestion. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype public_network_access_for_ingestion: str or + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PublicNetworkAccessType + :keyword public_network_access_for_query: The network access type for accessing Application + Insights query. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype public_network_access_for_query: str or + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PublicNetworkAccessType + :keyword ingestion_mode: Indicates the flow of the ingestion. Possible values include: + "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", "LogAnalytics". Default + value: "LogAnalytics". + :paramtype ingestion_mode: str or + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.IngestionMode + :keyword disable_local_auth: Disable Non-AAD based Auth. + :paramtype disable_local_auth: bool + :keyword force_customer_storage_for_profiler: Force users to create their own storage account + for profiler and debugger. + :paramtype force_customer_storage_for_profiler: bool + """ super(ApplicationInsightsComponent, self).__init__(location=location, tags=tags, **kwargs) self.kind = kind self.etag = etag @@ -277,12 +341,12 @@ class ApplicationInsightsComponentListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of Application Insights component definitions. - :type value: + :ivar value: Required. List of Application Insights component definitions. + :vartype value: list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent] - :param next_link: The URI to get the next set of Application Insights component definitions if + :ivar next_link: The URI to get the next set of Application Insights component definitions if too many components where returned in the result set. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -301,6 +365,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. List of Application Insights component definitions. + :paramtype value: + list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent] + :keyword next_link: The URI to get the next set of Application Insights component definitions + if too many components where returned in the result set. + :paramtype next_link: str + """ super(ApplicationInsightsComponentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -311,11 +383,11 @@ class ComponentPurgeBody(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param table: Required. Table from which to purge data. - :type table: str - :param filters: Required. The set of columns and filters (queries) to run over them to purge - the resulting data. - :type filters: + :ivar table: Required. Table from which to purge data. + :vartype table: str + :ivar filters: Required. The set of columns and filters (queries) to run over them to purge the + resulting data. + :vartype filters: list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeBodyFilters] """ @@ -336,6 +408,14 @@ def __init__( filters: List["ComponentPurgeBodyFilters"], **kwargs ): + """ + :keyword table: Required. Table from which to purge data. + :paramtype table: str + :keyword filters: Required. The set of columns and filters (queries) to run over them to purge + the resulting data. + :paramtype filters: + list[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ComponentPurgeBodyFilters] + """ super(ComponentPurgeBody, self).__init__(**kwargs) self.table = table self.filters = filters @@ -344,18 +424,18 @@ def __init__( class ComponentPurgeBodyFilters(msrest.serialization.Model): """User-defined filters to return data which will be purged from the table. - :param column: The column of the table over which the given query should run. - :type column: str - :param operator: A query operator to evaluate over the provided column and value(s). Supported + :ivar column: The column of the table over which the given query should run. + :vartype column: str + :ivar operator: A query operator to evaluate over the provided column and value(s). Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would in a KQL query. - :type operator: str - :param value: the value for the operator to function over. This can be a number (e.g., > 100), - a string (timestamp >= '2017-09-01') or array of values. - :type value: any - :param key: When filtering over custom dimensions, this key will be used as the name of the + :vartype operator: str + :ivar value: the value for the operator to function over. This can be a number (e.g., > 100), a + string (timestamp >= '2017-09-01') or array of values. + :vartype value: any + :ivar key: When filtering over custom dimensions, this key will be used as the name of the custom dimension. - :type key: str + :vartype key: str """ _attribute_map = { @@ -374,6 +454,20 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword column: The column of the table over which the given query should run. + :paramtype column: str + :keyword operator: A query operator to evaluate over the provided column and value(s). + Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as + they would in a KQL query. + :paramtype operator: str + :keyword value: the value for the operator to function over. This can be a number (e.g., > + 100), a string (timestamp >= '2017-09-01') or array of values. + :paramtype value: any + :keyword key: When filtering over custom dimensions, this key will be used as the name of the + custom dimension. + :paramtype key: str + """ super(ComponentPurgeBodyFilters, self).__init__(**kwargs) self.column = column self.operator = operator @@ -386,9 +480,9 @@ class ComponentPurgeResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param operation_id: Required. Id to use when querying for status for a particular purge + :ivar operation_id: Required. Id to use when querying for status for a particular purge operation. - :type operation_id: str + :vartype operation_id: str """ _validation = { @@ -405,6 +499,11 @@ def __init__( operation_id: str, **kwargs ): + """ + :keyword operation_id: Required. Id to use when querying for status for a particular purge + operation. + :paramtype operation_id: str + """ super(ComponentPurgeResponse, self).__init__(**kwargs) self.operation_id = operation_id @@ -414,9 +513,9 @@ class ComponentPurgeStatusResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the operation represented by the requested Id. Possible + :ivar status: Required. Status of the operation represented by the requested Id. Possible values include: "pending", "completed". - :type status: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PurgeState + :vartype status: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PurgeState """ _validation = { @@ -433,6 +532,11 @@ def __init__( status: Union[str, "PurgeState"], **kwargs ): + """ + :keyword status: Required. Status of the operation represented by the requested Id. Possible + values include: "pending", "completed". + :paramtype status: str or ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.PurgeState + """ super(ComponentPurgeStatusResponse, self).__init__(**kwargs) self.status = status @@ -462,6 +566,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -505,6 +611,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -516,8 +624,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ErrorDetail """ _attribute_map = { @@ -530,6 +638,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -537,10 +649,10 @@ def __init__( class PrivateLinkScopedResource(msrest.serialization.Model): """The private link scope resource reference. - :param resource_id: The full resource Id of the private link scope resource. - :type resource_id: str - :param scope_id: The private link scope unique Identifier. - :type scope_id: str + :ivar resource_id: The full resource Id of the private link scope resource. + :vartype resource_id: str + :ivar scope_id: The private link scope unique Identifier. + :vartype scope_id: str """ _attribute_map = { @@ -555,6 +667,12 @@ def __init__( scope_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: The full resource Id of the private link scope resource. + :paramtype resource_id: str + :keyword scope_id: The private link scope unique Identifier. + :paramtype scope_id: str + """ super(PrivateLinkScopedResource, self).__init__(**kwargs) self.resource_id = resource_id self.scope_id = scope_id @@ -563,8 +681,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a WebTest instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -577,5 +695,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py index 1bb47d83b1001..928ac3eb66efb 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_02_02_preview/operations/_components_operations.py @@ -5,23 +5,329 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_purge_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_purge_status_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + purge_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-02-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "purgeId": _SERIALIZER.url("purge_id", purge_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ComponentsOperations(object): """ComponentsOperations operations. @@ -45,16 +351,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsComponentListResult"] + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsComponentListResult"]: """Gets a list of all Application Insights components within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -62,34 +370,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,30 +405,33 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationInsightsComponentListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ApplicationInsightsComponentListResult"]: """Gets a list of Application Insights components within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationInsightsComponentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] + :return: An iterator like instance of either ApplicationInsightsComponentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationInsightsComponentListResult"] @@ -133,35 +439,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationInsightsComponentListResult', pipeline_response) + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,24 +476,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components'} # type: ignore + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Deletes an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -208,33 +511,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -242,13 +535,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Returns an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -265,33 +559,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplicationInsightsComponent', pipeline_response) @@ -300,16 +584,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - insight_properties, # type: "_models.ApplicationInsightsComponent" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + insight_properties: "_models.ApplicationInsightsComponent", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Creates (or updates) an Application Insights component. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. @@ -319,7 +605,8 @@ def create_or_update( :type resource_name: str :param insight_properties: Properties that need to be specified to create an Application Insights component. - :type insight_properties: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent + :type insight_properties: + ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationInsightsComponent, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_02_02_preview.models.ApplicationInsightsComponent @@ -330,38 +617,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(insight_properties, 'ApplicationInsightsComponent') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplicationInsightsComponent', pipeline_response) @@ -370,16 +647,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def update_tags( self, - resource_group_name, # type: str - resource_name, # type: str - component_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplicationInsightsComponent" + resource_group_name: str, + resource_name: str, + component_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.ApplicationInsightsComponent": """Updates an existing component's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -398,38 +677,28 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(component_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(component_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplicationInsightsComponent', pipeline_response) @@ -438,16 +707,18 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}'} # type: ignore + + @distributed_trace def purge( self, - resource_group_name, # type: str - resource_name, # type: str - body, # type: "_models.ComponentPurgeBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentPurgeResponse" + resource_group_name: str, + resource_name: str, + body: "_models.ComponentPurgeBody", + **kwargs: Any + ) -> "_models.ComponentPurgeResponse": """Purges data in an Application Insights component by a set of user-defined filters. In order to manage system resources, purge requests are throttled at 50 requests per hour. You @@ -473,38 +744,28 @@ def purge( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.purge.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(body, 'ComponentPurgeBody') + + request = build_purge_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.purge.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'ComponentPurgeBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentPurgeResponse', pipeline_response) @@ -513,16 +774,18 @@ def purge( return cls(pipeline_response, deserialized, {}) return deserialized + purge.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge'} # type: ignore + + @distributed_trace def get_purge_status( self, - resource_group_name, # type: str - resource_name, # type: str - purge_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentPurgeStatusResponse" + resource_group_name: str, + resource_name: str, + purge_id: str, + **kwargs: Any + ) -> "_models.ComponentPurgeStatusResponse": """Get status for an ongoing purge operation. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -542,34 +805,24 @@ def get_purge_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-02-preview" - accept = "application/json" - - # Construct URL - url = self.get_purge_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'purgeId': self._serialize.url("purge_id", purge_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_purge_status_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + purge_id=purge_id, + template_url=self.get_purge_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentPurgeStatusResponse', pipeline_response) @@ -578,4 +831,6 @@ def get_purge_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_purge_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py index 48ef506c72497..29106bc2a6c09 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_application_insights_management_client.py @@ -6,73 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import ComponentLinkedStorageAccountsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar component_linked_storage_accounts: ComponentLinkedStorageAccountsOperations operations - :vartype component_linked_storage_accounts: azure.mgmt.applicationinsights.v2020_03_01_preview.operations.ComponentLinkedStorageAccountsOperations + :vartype component_linked_storage_accounts: + azure.mgmt.applicationinsights.v2020_03_01_preview.operations.ComponentLinkedStorageAccountsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py index b7e04d1ad26d4..697874aa4d757 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json index e49b2173b2b6a..5b75ee7a96d1e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "component_linked_storage_accounts": "ComponentLinkedStorageAccountsOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py index 8b31a683d074f..fce03dad99857 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_application_insights_management_client.py @@ -6,69 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import ComponentLinkedStorageAccountsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar component_linked_storage_accounts: ComponentLinkedStorageAccountsOperations operations - :vartype component_linked_storage_accounts: azure.mgmt.applicationinsights.v2020_03_01_preview.aio.operations.ComponentLinkedStorageAccountsOperations + :vartype component_linked_storage_accounts: + azure.mgmt.applicationinsights.v2020_03_01_preview.aio.operations.ComponentLinkedStorageAccountsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py index fe02d18ebfa95..c89ab9cf66aa0 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py index 222ff5f85c550..8da94d64e05b2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/aio/operations/_component_linked_storage_accounts_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._component_linked_storage_accounts_operations import build_create_and_update_request, build_delete_request, build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -55,10 +60,12 @@ async def get( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :rtype: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ComponentLinkedStorageAccounts"] @@ -66,34 +73,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentLinkedStorageAccounts', pipeline_response) @@ -102,8 +99,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + + @distributed_trace_async async def create_and_update( self, resource_group_name: str, @@ -120,13 +120,16 @@ async def create_and_update( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update linked storage accounts for an Application Insights component. - :type linked_storage_accounts_properties: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :rtype: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ComponentLinkedStorageAccounts"] @@ -134,39 +137,29 @@ async def create_and_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_and_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccounts') + + request = build_create_and_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + content_type=content_type, + json=_json, + template_url=self.create_and_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccounts') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentLinkedStorageAccounts', pipeline_response) @@ -175,8 +168,11 @@ async def create_and_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_and_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -193,13 +189,16 @@ async def update( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update a linked storage accounts for an Application Insights component. - :type linked_storage_accounts_properties: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccountsPatch + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccountsPatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :rtype: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ComponentLinkedStorageAccounts"] @@ -207,39 +206,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccountsPatch') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccountsPatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentLinkedStorageAccounts', pipeline_response) @@ -248,8 +237,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -265,7 +257,8 @@ async def delete( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -276,37 +269,28 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py index 5ddf539119e58..ff6f48c5911b1 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/__init__.py @@ -6,20 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ComponentLinkedStorageAccounts - from ._models_py3 import ComponentLinkedStorageAccountsPatch - from ._models_py3 import ErrorResponseLinkedStorage - from ._models_py3 import ErrorResponseLinkedStorageError - from ._models_py3 import ProxyResource - from ._models_py3 import Resource -except (SyntaxError, ImportError): - from ._models import ComponentLinkedStorageAccounts # type: ignore - from ._models import ComponentLinkedStorageAccountsPatch # type: ignore - from ._models import ErrorResponseLinkedStorage # type: ignore - from ._models import ErrorResponseLinkedStorageError # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Resource # type: ignore +from ._models_py3 import ComponentLinkedStorageAccounts +from ._models_py3 import ComponentLinkedStorageAccountsPatch +from ._models_py3 import ErrorResponseLinkedStorage +from ._models_py3 import ErrorResponseLinkedStorageError +from ._models_py3 import ProxyResource +from ._models_py3 import Resource + from ._application_insights_management_client_enums import ( StorageType, diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_application_insights_management_client_enums.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_application_insights_management_client_enums.py index 72c225a5ed235..34257ee7c4a1f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_application_insights_management_client_enums.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_application_insights_management_client_enums.py @@ -6,26 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class StorageType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE_PROFILER = "ServiceProfiler" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models.py deleted file mode 100644 index b05bb6de3022d..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models.py +++ /dev/null @@ -1,189 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class ComponentLinkedStorageAccounts(ProxyResource): - """An Application Insights component linked storage accounts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param linked_storage_account: Linked storage account resource ID. - :type linked_storage_account: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'linked_storage_account': {'key': 'properties.linkedStorageAccount', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentLinkedStorageAccounts, self).__init__(**kwargs) - self.linked_storage_account = kwargs.get('linked_storage_account', None) - - -class ComponentLinkedStorageAccountsPatch(msrest.serialization.Model): - """An Application Insights component linked storage accounts patch. - - :param linked_storage_account: Linked storage account resource ID. - :type linked_storage_account: str - """ - - _attribute_map = { - 'linked_storage_account': {'key': 'properties.linkedStorageAccount', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentLinkedStorageAccountsPatch, self).__init__(**kwargs) - self.linked_storage_account = kwargs.get('linked_storage_account', None) - - -class ErrorResponseLinkedStorage(msrest.serialization.Model): - """ErrorResponseLinkedStorage. - - :param error: Error response indicates Insights service is not able to process the incoming - request. The reason is provided in the error message. - :type error: - ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ErrorResponseLinkedStorageError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseLinkedStorageError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseLinkedStorage, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseLinkedStorageError(msrest.serialization.Model): - """Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseLinkedStorageError, self).__init__(**kwargs) - self.code = None - self.message = None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py index 2e7eaa0fcba80..bfbde449f038a 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/models/_models_py3.py @@ -43,6 +43,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -80,6 +82,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) @@ -96,8 +100,8 @@ class ComponentLinkedStorageAccounts(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param linked_storage_account: Linked storage account resource ID. - :type linked_storage_account: str + :ivar linked_storage_account: Linked storage account resource ID. + :vartype linked_storage_account: str """ _validation = { @@ -119,6 +123,10 @@ def __init__( linked_storage_account: Optional[str] = None, **kwargs ): + """ + :keyword linked_storage_account: Linked storage account resource ID. + :paramtype linked_storage_account: str + """ super(ComponentLinkedStorageAccounts, self).__init__(**kwargs) self.linked_storage_account = linked_storage_account @@ -126,8 +134,8 @@ def __init__( class ComponentLinkedStorageAccountsPatch(msrest.serialization.Model): """An Application Insights component linked storage accounts patch. - :param linked_storage_account: Linked storage account resource ID. - :type linked_storage_account: str + :ivar linked_storage_account: Linked storage account resource ID. + :vartype linked_storage_account: str """ _attribute_map = { @@ -140,6 +148,10 @@ def __init__( linked_storage_account: Optional[str] = None, **kwargs ): + """ + :keyword linked_storage_account: Linked storage account resource ID. + :paramtype linked_storage_account: str + """ super(ComponentLinkedStorageAccountsPatch, self).__init__(**kwargs) self.linked_storage_account = linked_storage_account @@ -147,9 +159,9 @@ def __init__( class ErrorResponseLinkedStorage(msrest.serialization.Model): """ErrorResponseLinkedStorage. - :param error: Error response indicates Insights service is not able to process the incoming + :ivar error: Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - :type error: + :vartype error: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ErrorResponseLinkedStorageError """ @@ -163,6 +175,12 @@ def __init__( error: Optional["ErrorResponseLinkedStorageError"] = None, **kwargs ): + """ + :keyword error: Error response indicates Insights service is not able to process the incoming + request. The reason is provided in the error message. + :paramtype error: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ErrorResponseLinkedStorageError + """ super(ErrorResponseLinkedStorage, self).__init__(**kwargs) self.error = error @@ -192,6 +210,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponseLinkedStorageError, self).__init__(**kwargs) self.code = None self.message = None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py index 3db060fc7081a..dc7db33942e29 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_03_01_preview/operations/_component_linked_storage_accounts_operations.py @@ -5,22 +5,191 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "storageType": _SERIALIZER.url("storage_type", storage_type, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_and_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "storageType": _SERIALIZER.url("storage_type", storage_type, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "storageType": _SERIALIZER.url("storage_type", storage_type, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + subscription_id: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "storageType": _SERIALIZER.url("storage_type", storage_type, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ComponentLinkedStorageAccountsOperations(object): """ComponentLinkedStorageAccountsOperations operations. @@ -44,14 +213,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - storage_type, # type: Union[str, "_models.StorageType"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentLinkedStorageAccounts" + resource_group_name: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + **kwargs: Any + ) -> "_models.ComponentLinkedStorageAccounts": """Returns the current linked storage settings for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -60,10 +229,12 @@ def get( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :rtype: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ComponentLinkedStorageAccounts"] @@ -71,34 +242,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentLinkedStorageAccounts', pipeline_response) @@ -107,17 +268,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + + @distributed_trace def create_and_update( self, - resource_group_name, # type: str - resource_name, # type: str - storage_type, # type: Union[str, "_models.StorageType"] - linked_storage_accounts_properties, # type: "_models.ComponentLinkedStorageAccounts" - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentLinkedStorageAccounts" + resource_group_name: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + linked_storage_accounts_properties: "_models.ComponentLinkedStorageAccounts", + **kwargs: Any + ) -> "_models.ComponentLinkedStorageAccounts": """Replace current linked storage account for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -126,13 +289,16 @@ def create_and_update( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update linked storage accounts for an Application Insights component. - :type linked_storage_accounts_properties: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :rtype: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ComponentLinkedStorageAccounts"] @@ -140,39 +306,29 @@ def create_and_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_and_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccounts') + + request = build_create_and_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + content_type=content_type, + json=_json, + template_url=self.create_and_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccounts') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentLinkedStorageAccounts', pipeline_response) @@ -181,17 +337,19 @@ def create_and_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_and_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - storage_type, # type: Union[str, "_models.StorageType"] - linked_storage_accounts_properties, # type: "_models.ComponentLinkedStorageAccountsPatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.ComponentLinkedStorageAccounts" + resource_group_name: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + linked_storage_accounts_properties: "_models.ComponentLinkedStorageAccountsPatch", + **kwargs: Any + ) -> "_models.ComponentLinkedStorageAccounts": """Update linked storage accounts for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -200,13 +358,16 @@ def update( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :param linked_storage_accounts_properties: Properties that need to be specified to update a linked storage accounts for an Application Insights component. - :type linked_storage_accounts_properties: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccountsPatch + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccountsPatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentLinkedStorageAccounts, or the result of cls(response) - :rtype: ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts + :rtype: + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.ComponentLinkedStorageAccounts :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ComponentLinkedStorageAccounts"] @@ -214,39 +375,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccountsPatch') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(linked_storage_accounts_properties, 'ComponentLinkedStorageAccountsPatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ComponentLinkedStorageAccounts', pipeline_response) @@ -255,16 +406,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - storage_type, # type: Union[str, "_models.StorageType"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + storage_type: Union[str, "_models.StorageType"], + **kwargs: Any + ) -> None: """Delete linked storage accounts for an Application Insights component. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -273,7 +426,8 @@ def delete( :type resource_name: str :param storage_type: The type of the Application Insights component data source for the linked storage account. - :type storage_type: str or ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType + :type storage_type: str or + ~azure.mgmt.applicationinsights.v2020_03_01_preview.models.StorageType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -284,37 +438,28 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'storageType': self._serialize.url("storage_type", storage_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + resource_name=resource_name, + storage_type=storage_type, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py index 9fec118a8b5c8..644fe265af0ea 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_application_insights_management_client.py @@ -6,72 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import LiveTokenOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import Operations -from .operations import LiveTokenOperations -from . import models - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.applicationinsights.v2020_06_02_preview.operations.Operations :ivar live_token: LiveTokenOperations operations - :vartype live_token: azure.mgmt.applicationinsights.v2020_06_02_preview.operations.LiveTokenOperations + :vartype live_token: + azure.mgmt.applicationinsights.v2020_06_02_preview.operations.LiveTokenOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.live_token = LiveTokenOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py index 17c69526535ff..549178067c212 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2020-06-02-preview" @@ -62,4 +59,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json index 721a11115abfc..805d7dc4a8aeb 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py index f41dd2f4be1ec..45f74703e1c3e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_application_insights_management_client.py @@ -6,68 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import LiveTokenOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ApplicationInsightsManagementClientConfiguration -from .operations import Operations -from .operations import LiveTokenOperations -from .. import models - - -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar operations: Operations operations - :vartype operations: azure.mgmt.applicationinsights.v2020_06_02_preview.aio.operations.Operations + :vartype operations: + azure.mgmt.applicationinsights.v2020_06_02_preview.aio.operations.Operations :ivar live_token: LiveTokenOperations operations - :vartype live_token: azure.mgmt.applicationinsights.v2020_06_02_preview.aio.operations.LiveTokenOperations + :vartype live_token: + azure.mgmt.applicationinsights.v2020_06_02_preview.aio.operations.LiveTokenOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.live_token = LiveTokenOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py index a91950e540b89..c530ed6488c1c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2020-06-02-preview" @@ -58,4 +58,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py index b37a339c25233..8be7b8e6e8fd0 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_live_token_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._live_token_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -59,31 +64,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-02-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_uri=resource_uri, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LiveTokenResponse', pipeline_response) @@ -92,4 +87,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/generatelivetoken'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py index 30d9d767fc61b..b39c432cd9e92 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -50,8 +56,10 @@ def list( List the available operations supported by the resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationsListResult] + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] @@ -59,30 +67,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-02-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,6 +105,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py index 98bce08b972dd..0f1798e3f2016 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/__init__.py @@ -6,20 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorResponseLinkedStorage - from ._models_py3 import ErrorResponseLinkedStorageError - from ._models_py3 import LiveTokenResponse - from ._models_py3 import OperationInfo - from ._models_py3 import OperationLive - from ._models_py3 import OperationsListResult -except (SyntaxError, ImportError): - from ._models import ErrorResponseLinkedStorage # type: ignore - from ._models import ErrorResponseLinkedStorageError # type: ignore - from ._models import LiveTokenResponse # type: ignore - from ._models import OperationInfo # type: ignore - from ._models import OperationLive # type: ignore - from ._models import OperationsListResult # type: ignore +from ._models_py3 import ErrorResponseLinkedStorage +from ._models_py3 import ErrorResponseLinkedStorageError +from ._models_py3 import LiveTokenResponse +from ._models_py3 import OperationInfo +from ._models_py3 import OperationLive +from ._models_py3 import OperationsListResult + __all__ = [ 'ErrorResponseLinkedStorage', diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models.py deleted file mode 100644 index cec4eaba97575..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models.py +++ /dev/null @@ -1,171 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorResponseLinkedStorage(msrest.serialization.Model): - """ErrorResponseLinkedStorage. - - :param error: Error response indicates Insights service is not able to process the incoming - request. The reason is provided in the error message. - :type error: - ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.ErrorResponseLinkedStorageError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseLinkedStorageError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseLinkedStorage, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseLinkedStorageError(msrest.serialization.Model): - """Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseLinkedStorageError, self).__init__(**kwargs) - self.code = None - self.message = None - - -class LiveTokenResponse(msrest.serialization.Model): - """The response to a live token query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar live_token: JWT token for accessing live metrics stream data. - :vartype live_token: str - """ - - _validation = { - 'live_token': {'readonly': True}, - } - - _attribute_map = { - 'live_token': {'key': 'liveToken', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LiveTokenResponse, self).__init__(**kwargs) - self.live_token = None - - -class OperationInfo(msrest.serialization.Model): - """Information about an operation. - - :param provider: Name of the provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the operation. - :type operation: str - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInfo, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationLive(msrest.serialization.Model): - """Represents an operation returned by the GetOperations request. - - :param name: Name of the operation. - :type name: str - :param display: Display name of the operation. - :type display: ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationInfo - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: any - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationInfo'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationLive, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class OperationsListResult(msrest.serialization.Model): - """Result of the List Operations operation. - - :param value: A collection of operations. - :type value: list[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationLive] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationLive]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py index dc72f43a22d30..8ed9fcc36b992 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/models/_models_py3.py @@ -15,9 +15,9 @@ class ErrorResponseLinkedStorage(msrest.serialization.Model): """ErrorResponseLinkedStorage. - :param error: Error response indicates Insights service is not able to process the incoming + :ivar error: Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. - :type error: + :vartype error: ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.ErrorResponseLinkedStorageError """ @@ -31,6 +31,12 @@ def __init__( error: Optional["ErrorResponseLinkedStorageError"] = None, **kwargs ): + """ + :keyword error: Error response indicates Insights service is not able to process the incoming + request. The reason is provided in the error message. + :paramtype error: + ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.ErrorResponseLinkedStorageError + """ super(ErrorResponseLinkedStorage, self).__init__(**kwargs) self.error = error @@ -60,6 +66,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponseLinkedStorageError, self).__init__(**kwargs) self.code = None self.message = None @@ -86,6 +94,8 @@ def __init__( self, **kwargs ): + """ + """ super(LiveTokenResponse, self).__init__(**kwargs) self.live_token = None @@ -93,14 +103,14 @@ def __init__( class OperationInfo(msrest.serialization.Model): """Information about an operation. - :param provider: Name of the provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the operation. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Name of the provider. + :vartype provider: str + :ivar resource: Name of the resource type. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -119,6 +129,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Name of the provider. + :paramtype provider: str + :keyword resource: Name of the resource type. + :paramtype resource: str + :keyword operation: Name of the operation. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationInfo, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -129,14 +149,14 @@ def __init__( class OperationLive(msrest.serialization.Model): """Represents an operation returned by the GetOperations request. - :param name: Name of the operation. - :type name: str - :param display: Display name of the operation. - :type display: ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationInfo - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: any + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Display name of the operation. + :vartype display: ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationInfo + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: any """ _attribute_map = { @@ -155,6 +175,16 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Display name of the operation. + :paramtype display: ~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationInfo + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: any + """ super(OperationLive, self).__init__(**kwargs) self.name = name self.display = display @@ -165,10 +195,10 @@ def __init__( class OperationsListResult(msrest.serialization.Model): """Result of the List Operations operation. - :param value: A collection of operations. - :type value: list[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationLive] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: A collection of operations. + :vartype value: list[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationLive] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -183,6 +213,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of operations. + :paramtype value: + list[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationLive] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py index 0bf84aaec4214..fcf48c58b0b1d 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_live_token_operations.py @@ -5,22 +5,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/generatelivetoken') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LiveTokenOperations(object): """LiveTokenOperations operations. @@ -44,12 +77,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LiveTokenResponse" + resource_uri: str, + **kwargs: Any + ) -> "_models.LiveTokenResponse": """**Gets an access token for live metrics stream data.**. :param resource_uri: The identifier of the resource. @@ -64,31 +97,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-02-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_uri=resource_uri, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseLinkedStorage, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LiveTokenResponse', pipeline_response) @@ -97,4 +120,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/generatelivetoken'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py index 253fcd295c4c7..d686a7cba9939 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_06_02_preview/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-02-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/microsoft.insights/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,18 +72,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationsListResult"]: """List available operations. List the available operations supported by the resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationsListResult] + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_06_02_preview.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] @@ -64,30 +93,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-02-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,6 +131,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py index 1a10819f3baf2..3939725a372b2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_application_insights_management_client.py @@ -6,73 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import WorkbookTemplatesOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations - :vartype workbook_templates: azure.mgmt.applicationinsights.v2020_11_20.operations.WorkbookTemplatesOperations + :vartype workbook_templates: + azure.mgmt.applicationinsights.v2020_11_20.operations.WorkbookTemplatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbook_templates = WorkbookTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py index 21f3a189fd679..aea20defadd7f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json index 99d580710f824..76b3ae6d078c2 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbook_templates": "WorkbookTemplatesOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py index 267ba5a3700e6..bf1433871ed38 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_application_insights_management_client.py @@ -6,69 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import WorkbookTemplatesOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbook_templates: WorkbookTemplatesOperations operations - :vartype workbook_templates: azure.mgmt.applicationinsights.v2020_11_20.aio.operations.WorkbookTemplatesOperations + :vartype workbook_templates: + azure.mgmt.applicationinsights.v2020_11_20.aio.operations.WorkbookTemplatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbook_templates = WorkbookTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbook_templates = WorkbookTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py index 56da0baeab867..ce421b53663f8 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py index 25b44f5dbe31c..712dc6328b76f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/aio/operations/_workbook_templates_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._workbook_templates_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -51,8 +57,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkbookTemplatesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplatesListResult] + :return: An iterator like instance of either WorkbookTemplatesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplatesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbookTemplatesListResult"] @@ -60,35 +68,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbookTemplatesListResult', pipeline_response) + deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +105,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -134,33 +140,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -169,8 +165,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -193,33 +192,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +216,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -242,7 +233,8 @@ async def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. - :type workbook_template_properties: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate + :type workbook_template_properties: + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate @@ -253,38 +245,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -297,8 +279,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -314,7 +299,8 @@ async def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. - :type workbook_template_update_parameters: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate @@ -325,41 +311,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if workbook_template_update_parameters is not None: - body_content = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') + _json = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -368,4 +344,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py index 69a12ceea24b0..47a565a632160 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/__init__.py @@ -6,26 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import WorkbookTemplate - from ._models_py3 import WorkbookTemplateError - from ._models_py3 import WorkbookTemplateErrorBody - from ._models_py3 import WorkbookTemplateErrorFieldContract - from ._models_py3 import WorkbookTemplateGallery - from ._models_py3 import WorkbookTemplateLocalizedGallery - from ._models_py3 import WorkbookTemplateResource - from ._models_py3 import WorkbookTemplateUpdateParameters - from ._models_py3 import WorkbookTemplatesListResult -except (SyntaxError, ImportError): - from ._models import WorkbookTemplate # type: ignore - from ._models import WorkbookTemplateError # type: ignore - from ._models import WorkbookTemplateErrorBody # type: ignore - from ._models import WorkbookTemplateErrorFieldContract # type: ignore - from ._models import WorkbookTemplateGallery # type: ignore - from ._models import WorkbookTemplateLocalizedGallery # type: ignore - from ._models import WorkbookTemplateResource # type: ignore - from ._models import WorkbookTemplateUpdateParameters # type: ignore - from ._models import WorkbookTemplatesListResult # type: ignore +from ._models_py3 import WorkbookTemplate +from ._models_py3 import WorkbookTemplateError +from ._models_py3 import WorkbookTemplateErrorBody +from ._models_py3 import WorkbookTemplateErrorFieldContract +from ._models_py3 import WorkbookTemplateGallery +from ._models_py3 import WorkbookTemplateLocalizedGallery +from ._models_py3 import WorkbookTemplateResource +from ._models_py3 import WorkbookTemplateUpdateParameters +from ._models_py3 import WorkbookTemplatesListResult + __all__ = [ 'WorkbookTemplate', diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models.py deleted file mode 100644 index a1c0bf77dbf52..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models.py +++ /dev/null @@ -1,317 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class WorkbookTemplateResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class WorkbookTemplate(WorkbookTemplateResource): - """An Application Insights workbook template definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook - gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: - list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages - supported by the Azure portal. - :type localized: dict[str, - list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateLocalizedGallery]] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'priority': {'key': 'properties.priority', 'type': 'int'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'template_data': {'key': 'properties.templateData', 'type': 'object'}, - 'galleries': {'key': 'properties.galleries', 'type': '[WorkbookTemplateGallery]'}, - 'localized': {'key': 'properties.localized', 'type': '{[WorkbookTemplateLocalizedGallery]}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplate, self).__init__(**kwargs) - self.priority = kwargs.get('priority', None) - self.author = kwargs.get('author', None) - self.template_data = kwargs.get('template_data', None) - self.galleries = kwargs.get('galleries', None) - self.localized = kwargs.get('localized', None) - - -class WorkbookTemplateError(msrest.serialization.Model): - """Error message that will indicate why the operation failed. - - :param error: Error message object that will indicate why the operation failed. - :type error: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'WorkbookTemplateErrorBody'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class WorkbookTemplateErrorBody(msrest.serialization.Model): - """Error message body that will indicate why the operation failed. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: - list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateErrorFieldContract] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[WorkbookTemplateErrorFieldContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class WorkbookTemplateErrorFieldContract(msrest.serialization.Model): - """Error Field contract. - - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateErrorFieldContract, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - - -class WorkbookTemplateGallery(msrest.serialization.Model): - """Gallery information for a workbook template. - - :param name: Name of the workbook template in the gallery. - :type name: str - :param category: Category for the gallery. - :type category: str - :param type: Type of workbook supported by the workbook template. - :type type: str - :param order: Order of the template within the gallery. - :type order: int - :param resource_type: Azure resource type supported by the gallery. - :type resource_type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'order': {'key': 'order', 'type': 'int'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateGallery, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.category = kwargs.get('category', None) - self.type = kwargs.get('type', None) - self.order = kwargs.get('order', None) - self.resource_type = kwargs.get('resource_type', None) - - -class WorkbookTemplateLocalizedGallery(msrest.serialization.Model): - """Localized template data and gallery information. - - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: - list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] - """ - - _attribute_map = { - 'template_data': {'key': 'templateData', 'type': 'object'}, - 'galleries': {'key': 'galleries', 'type': '[WorkbookTemplateGallery]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateLocalizedGallery, self).__init__(**kwargs) - self.template_data = kwargs.get('template_data', None) - self.galleries = kwargs.get('galleries', None) - - -class WorkbookTemplatesListResult(msrest.serialization.Model): - """WorkbookTemplate list result. - - :param value: An array of workbook templates. - :type value: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkbookTemplate]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplatesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class WorkbookTemplateUpdateParameters(msrest.serialization.Model): - """The parameters that can be provided when updating workbook template. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook - gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: - list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages - supported by the Azure portal. - :type localized: dict[str, - list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateLocalizedGallery]] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'priority': {'key': 'properties.priority', 'type': 'int'}, - 'author': {'key': 'properties.author', 'type': 'str'}, - 'template_data': {'key': 'properties.templateData', 'type': 'object'}, - 'galleries': {'key': 'properties.galleries', 'type': '[WorkbookTemplateGallery]'}, - 'localized': {'key': 'properties.localized', 'type': '{[WorkbookTemplateLocalizedGallery]}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookTemplateUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.priority = kwargs.get('priority', None) - self.author = kwargs.get('author', None) - self.template_data = kwargs.get('template_data', None) - self.galleries = kwargs.get('galleries', None) - self.localized = kwargs.get('localized', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py index e454306856771..c481328df177c 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/models/_models_py3.py @@ -25,10 +25,10 @@ class WorkbookTemplateResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -53,6 +53,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(WorkbookTemplateResource, self).__init__(**kwargs) self.id = None self.name = None @@ -74,23 +80,23 @@ class WorkbookTemplate(WorkbookTemplateResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar priority: Priority of the template. Determines which template to open when a workbook gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: + :vartype priority: int + :ivar author: Information about the author of the workbook template. + :vartype author: str + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: any + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages + :ivar localized: Key value pair of localized gallery. Each key is the locale code of languages supported by the Azure portal. - :type localized: dict[str, + :vartype localized: dict[str, list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateLocalizedGallery]] """ @@ -126,6 +132,26 @@ def __init__( localized: Optional[Dict[str, List["WorkbookTemplateLocalizedGallery"]]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :paramtype priority: int + :keyword author: Information about the author of the workbook template. + :paramtype author: str + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: any + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: + list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] + :keyword localized: Key value pair of localized gallery. Each key is the locale code of + languages supported by the Azure portal. + :paramtype localized: dict[str, + list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateLocalizedGallery]] + """ super(WorkbookTemplate, self).__init__(location=location, tags=tags, **kwargs) self.priority = priority self.author = author @@ -137,8 +163,8 @@ def __init__( class WorkbookTemplateError(msrest.serialization.Model): """Error message that will indicate why the operation failed. - :param error: Error message object that will indicate why the operation failed. - :type error: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateErrorBody + :ivar error: Error message object that will indicate why the operation failed. + :vartype error: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateErrorBody """ _attribute_map = { @@ -151,6 +177,10 @@ def __init__( error: Optional["WorkbookTemplateErrorBody"] = None, **kwargs ): + """ + :keyword error: Error message object that will indicate why the operation failed. + :paramtype error: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateErrorBody + """ super(WorkbookTemplateError, self).__init__(**kwargs) self.error = error @@ -158,13 +188,13 @@ def __init__( class WorkbookTemplateErrorBody(msrest.serialization.Model): """Error message body that will indicate why the operation failed. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateErrorFieldContract] """ @@ -182,6 +212,16 @@ def __init__( details: Optional[List["WorkbookTemplateErrorFieldContract"]] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: + list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateErrorFieldContract] + """ super(WorkbookTemplateErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -191,12 +231,12 @@ def __init__( class WorkbookTemplateErrorFieldContract(msrest.serialization.Model): """Error Field contract. - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str """ _attribute_map = { @@ -213,6 +253,14 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword code: Property level error code. + :paramtype code: str + :keyword message: Human-readable representation of property-level error. + :paramtype message: str + :keyword target: Property name. + :paramtype target: str + """ super(WorkbookTemplateErrorFieldContract, self).__init__(**kwargs) self.code = code self.message = message @@ -222,16 +270,16 @@ def __init__( class WorkbookTemplateGallery(msrest.serialization.Model): """Gallery information for a workbook template. - :param name: Name of the workbook template in the gallery. - :type name: str - :param category: Category for the gallery. - :type category: str - :param type: Type of workbook supported by the workbook template. - :type type: str - :param order: Order of the template within the gallery. - :type order: int - :param resource_type: Azure resource type supported by the gallery. - :type resource_type: str + :ivar name: Name of the workbook template in the gallery. + :vartype name: str + :ivar category: Category for the gallery. + :vartype category: str + :ivar type: Type of workbook supported by the workbook template. + :vartype type: str + :ivar order: Order of the template within the gallery. + :vartype order: int + :ivar resource_type: Azure resource type supported by the gallery. + :vartype resource_type: str """ _attribute_map = { @@ -252,6 +300,18 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the workbook template in the gallery. + :paramtype name: str + :keyword category: Category for the gallery. + :paramtype category: str + :keyword type: Type of workbook supported by the workbook template. + :paramtype type: str + :keyword order: Order of the template within the gallery. + :paramtype order: int + :keyword resource_type: Azure resource type supported by the gallery. + :paramtype resource_type: str + """ super(WorkbookTemplateGallery, self).__init__(**kwargs) self.name = name self.category = category @@ -263,10 +323,10 @@ def __init__( class WorkbookTemplateLocalizedGallery(msrest.serialization.Model): """Localized template data and gallery information. - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: any + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] """ @@ -282,6 +342,13 @@ def __init__( galleries: Optional[List["WorkbookTemplateGallery"]] = None, **kwargs ): + """ + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: any + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: + list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] + """ super(WorkbookTemplateLocalizedGallery, self).__init__(**kwargs) self.template_data = template_data self.galleries = galleries @@ -290,8 +357,8 @@ def __init__( class WorkbookTemplatesListResult(msrest.serialization.Model): """WorkbookTemplate list result. - :param value: An array of workbook templates. - :type value: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate] + :ivar value: An array of workbook templates. + :vartype value: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate] """ _attribute_map = { @@ -304,6 +371,10 @@ def __init__( value: Optional[List["WorkbookTemplate"]] = None, **kwargs ): + """ + :keyword value: An array of workbook templates. + :paramtype value: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate] + """ super(WorkbookTemplatesListResult, self).__init__(**kwargs) self.value = value @@ -311,21 +382,21 @@ def __init__( class WorkbookTemplateUpdateParameters(msrest.serialization.Model): """The parameters that can be provided when updating workbook template. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param priority: Priority of the template. Determines which template to open when a workbook + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar priority: Priority of the template. Determines which template to open when a workbook gallery is opened in viewer mode. - :type priority: int - :param author: Information about the author of the workbook template. - :type author: str - :param template_data: Valid JSON object containing workbook template payload. - :type template_data: any - :param galleries: Workbook galleries supported by the template. - :type galleries: + :vartype priority: int + :ivar author: Information about the author of the workbook template. + :vartype author: str + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: any + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] - :param localized: Key value pair of localized gallery. Each key is the locale code of languages + :ivar localized: Key value pair of localized gallery. Each key is the locale code of languages supported by the Azure portal. - :type localized: dict[str, + :vartype localized: dict[str, list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateLocalizedGallery]] """ @@ -349,6 +420,24 @@ def __init__( localized: Optional[Dict[str, List["WorkbookTemplateLocalizedGallery"]]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :paramtype priority: int + :keyword author: Information about the author of the workbook template. + :paramtype author: str + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: any + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: + list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateGallery] + :keyword localized: Key value pair of localized gallery. Each key is the locale code of + languages supported by the Azure portal. + :paramtype localized: dict[str, + list[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateLocalizedGallery]] + """ super(WorkbookTemplateUpdateParameters, self).__init__(**kwargs) self.tags = tags self.priority = priority diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py index 7ff11b8ebf561..cfe7e16e2cd48 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2020_11_20/operations/_workbook_templates_operations.py @@ -5,23 +5,217 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-20" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-20" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-11-20" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-20" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-11-20" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class WorkbookTemplatesOperations(object): """WorkbookTemplatesOperations operations. @@ -45,19 +239,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkbookTemplatesListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkbookTemplatesListResult"]: """Get all Workbook templates defined within a specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkbookTemplatesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplatesListResult] + :return: An iterator like instance of either WorkbookTemplatesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplatesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbookTemplatesListResult"] @@ -65,35 +261,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbookTemplatesListResult', pipeline_response) + deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,24 +298,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkbookTemplate" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.WorkbookTemplate": """Get a single workbook template by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -140,33 +333,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -175,15 +358,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Delete a workbook template. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -200,33 +385,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,14 +409,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_template_properties, # type: "_models.WorkbookTemplate" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkbookTemplate" + resource_group_name: str, + resource_name: str, + workbook_template_properties: "_models.WorkbookTemplate", + **kwargs: Any + ) -> "_models.WorkbookTemplate": """Create a new workbook template. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -250,7 +426,8 @@ def create_or_update( :type resource_name: str :param workbook_template_properties: Properties that need to be specified to create a new workbook. - :type workbook_template_properties: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate + :type workbook_template_properties: + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate @@ -261,38 +438,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_template_properties, 'WorkbookTemplate') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -305,16 +472,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_template_update_parameters=None, # type: Optional["_models.WorkbookTemplateUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkbookTemplate" + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional["_models.WorkbookTemplateUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.WorkbookTemplate": """Updates a workbook template that has already been added. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -323,7 +492,8 @@ def update( :type resource_name: str :param workbook_template_update_parameters: Properties that need to be specified to patch a workbook template. - :type workbook_template_update_parameters: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkbookTemplate, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2020_11_20.models.WorkbookTemplate @@ -334,41 +504,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-11-20" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if workbook_template_update_parameters is not None: - body_content = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') + _json = self._serialize.body(workbook_template_update_parameters, 'WorkbookTemplateUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('WorkbookTemplate', pipeline_response) @@ -377,4 +537,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py index e2ad0ee92d27e..1dc572ea6ae39 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_application_insights_management_client.py @@ -6,73 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import MyWorkbooksOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar my_workbooks: MyWorkbooksOperations operations - :vartype my_workbooks: azure.mgmt.applicationinsights.v2021_03_08.operations.MyWorkbooksOperations + :vartype my_workbooks: + azure.mgmt.applicationinsights.v2021_03_08.operations.MyWorkbooksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.my_workbooks = MyWorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py index 0d3b9b21c6353..b21c5898bfbea 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json index 6c2647f0772c2..51e4bbff7f412 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "my_workbooks": "MyWorkbooksOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py index 612648ce33c6d..acfbc84a68cac 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_application_insights_management_client.py @@ -6,69 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import MyWorkbooksOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar my_workbooks: MyWorkbooksOperations operations - :vartype my_workbooks: azure.mgmt.applicationinsights.v2021_03_08.aio.operations.MyWorkbooksOperations + :vartype my_workbooks: + azure.mgmt.applicationinsights.v2021_03_08.aio.operations.MyWorkbooksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.my_workbooks = MyWorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.my_workbooks = MyWorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py index b7fd0e64fdafc..f487117dec6e6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py index dae2c123f360c..66d4382dfc931 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/aio/operations/_my_workbooks_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._my_workbooks_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -64,8 +70,10 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -73,42 +81,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,17 +126,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace def list_by_subscription( self, category: Union[str, "_models.CategoryType"], @@ -149,8 +156,10 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -158,39 +167,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -203,17 +208,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -236,33 +243,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -271,8 +268,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -295,33 +295,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -329,6 +319,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -358,40 +350,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'MyWorkbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -404,8 +385,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -435,40 +419,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'MyWorkbook') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -477,4 +450,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py index 07b825a48b935..072358841cec9 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/__init__.py @@ -6,26 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorDefinition - from ._models_py3 import InnerErrorTrace - from ._models_py3 import MyWorkbook - from ._models_py3 import MyWorkbookError - from ._models_py3 import MyWorkbookManagedIdentity - from ._models_py3 import MyWorkbookResource - from ._models_py3 import MyWorkbookUserAssignedIdentities - from ._models_py3 import MyWorkbooksListResult - from ._models_py3 import SystemData -except (SyntaxError, ImportError): - from ._models import ErrorDefinition # type: ignore - from ._models import InnerErrorTrace # type: ignore - from ._models import MyWorkbook # type: ignore - from ._models import MyWorkbookError # type: ignore - from ._models import MyWorkbookManagedIdentity # type: ignore - from ._models import MyWorkbookResource # type: ignore - from ._models import MyWorkbookUserAssignedIdentities # type: ignore - from ._models import MyWorkbooksListResult # type: ignore - from ._models import SystemData # type: ignore +from ._models_py3 import ErrorDefinition +from ._models_py3 import InnerErrorTrace +from ._models_py3 import MyWorkbook +from ._models_py3 import MyWorkbookError +from ._models_py3 import MyWorkbookManagedIdentity +from ._models_py3 import MyWorkbookResource +from ._models_py3 import MyWorkbookUserAssignedIdentities +from ._models_py3 import MyWorkbooksListResult +from ._models_py3 import SystemData + from ._application_insights_management_client_enums import ( CategoryType, diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_application_insights_management_client_enums.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_application_insights_management_client_enums.py index be6863e0b0ba1..163b4395fb606 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_application_insights_management_client_enums.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_application_insights_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CategoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WORKBOOK = "workbook" TSG = "TSG" PERFORMANCE = "performance" RETENTION = "retention" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -42,14 +27,14 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class Kind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of workbook. Choices are user and shared. """ USER = "user" SHARED = "shared" -class MyWorkbookManagedIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MyWorkbookManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models.py deleted file mode 100644 index a1c8f33a76f7d..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models.py +++ /dev/null @@ -1,351 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorDefinition(msrest.serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar innererror: Internal error details. - :vartype innererror: any - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'innererror': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'innererror': {'key': 'innererror', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.code = None - self.message = None - self.innererror = None - - -class InnerErrorTrace(msrest.serialization.Model): - """Error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar trace: detailed error trace. - :vartype trace: list[str] - """ - - _validation = { - 'trace': {'readonly': True}, - } - - _attribute_map = { - 'trace': {'key': 'trace', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(InnerErrorTrace, self).__init__(**kwargs) - self.trace = None - - -class MyWorkbookResource(msrest.serialization.Model): - """An azure resource object. - - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param etag: Resource etag. - :type etag: dict[str, str] - """ - - _attribute_map = { - 'identity': {'key': 'identity', 'type': 'MyWorkbookManagedIdentity'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbookResource, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.etag = kwargs.get('etag', None) - - -class MyWorkbook(MyWorkbookResource): - """An Application Insights private workbook definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param etag: Resource etag. - :type etag: dict[str, str] - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.Kind - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.applicationinsights.v2021_03_08.models.SystemData - :param display_name: The user-defined name of the private workbook. - :type display_name: str - :param serialized_data: Configuration of this particular private workbook. Configuration data - is a string containing valid JSON. - :type serialized_data: str - :param version: This instance's version of the data model. This can change as new features are - added that can be marked private workbook. - :type version: str - :ivar time_modified: Date and time in UTC of the last modification that was made to this - private workbook definition. - :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this private - workbook definition. - :type tags_properties_tags: list[str] - :ivar user_id: Unique user id of the specific user that owns this private workbook. - :vartype user_id: str - :param source_id: Optional resourceId for a source resource. - :type source_id: str - :param storage_uri: BYOS Storage Account URI. - :type storage_uri: str - """ - - _validation = { - 'system_data': {'readonly': True}, - 'time_modified': {'readonly': True}, - 'user_id': {'readonly': True}, - } - - _attribute_map = { - 'identity': {'key': 'identity', 'type': 'MyWorkbookManagedIdentity'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'time_modified': {'key': 'properties.timeModified', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'tags_properties_tags': {'key': 'properties.tags', 'type': '[str]'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - 'source_id': {'key': 'properties.sourceId', 'type': 'str'}, - 'storage_uri': {'key': 'properties.storageUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbook, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.system_data = None - self.display_name = kwargs.get('display_name', None) - self.serialized_data = kwargs.get('serialized_data', None) - self.version = kwargs.get('version', None) - self.time_modified = None - self.category = kwargs.get('category', None) - self.tags_properties_tags = kwargs.get('tags_properties_tags', None) - self.user_id = None - self.source_id = kwargs.get('source_id', None) - self.storage_uri = kwargs.get('storage_uri', None) - - -class MyWorkbookError(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.applicationinsights.v2021_03_08.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbookError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class MyWorkbookManagedIdentity(msrest.serialization.Model): - """Customer Managed Identity. - - :param user_assigned_identities: Customer Managed Identity. - :type user_assigned_identities: - ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookUserAssignedIdentities - :param type: The identity type. Possible values include: "UserAssigned", "None". - :type type: str or - ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentityType - """ - - _attribute_map = { - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': 'MyWorkbookUserAssignedIdentities'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbookManagedIdentity, self).__init__(**kwargs) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - self.type = kwargs.get('type', None) - - -class MyWorkbooksListResult(msrest.serialization.Model): - """Workbook list result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of private workbooks. - :vartype value: list[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook] - :param next_link: - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MyWorkbook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbooksListResult, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class MyWorkbookUserAssignedIdentities(msrest.serialization.Model): - """Customer Managed Identity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MyWorkbookUserAssignedIdentities, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or - ~azure.mgmt.applicationinsights.v2021_03_08.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py index 4b7673c5c7670..c3410d2505ed0 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/models/_models_py3.py @@ -44,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -71,6 +73,8 @@ def __init__( self, **kwargs ): + """ + """ super(InnerErrorTrace, self).__init__(**kwargs) self.trace = None @@ -78,20 +82,20 @@ def __init__( class MyWorkbookResource(msrest.serialization.Model): """An azure resource object. - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param etag: Resource etag. - :type etag: dict[str, str] + :ivar identity: Identity used for BYOS. + :vartype identity: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar etag: Resource etag. + :vartype etag: dict[str, str] """ _attribute_map = { @@ -116,6 +120,23 @@ def __init__( etag: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword identity: Identity used for BYOS. + :paramtype identity: + ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity + :keyword id: Azure resource Id. + :paramtype id: str + :keyword name: Azure resource name. + :paramtype name: str + :keyword type: Azure resource type. + :paramtype type: str + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword etag: Resource etag. + :paramtype etag: dict[str, str] + """ super(MyWorkbookResource, self).__init__(**kwargs) self.identity = identity self.id = id @@ -131,47 +152,47 @@ class MyWorkbook(MyWorkbookResource): Variables are only populated by the server, and will be ignored when sending a request. - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity - :param id: Azure resource Id. - :type id: str - :param name: Azure resource name. - :type name: str - :param type: Azure resource type. - :type type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param etag: Resource etag. - :type etag: dict[str, str] - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.Kind + :ivar identity: Identity used for BYOS. + :vartype identity: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar etag: Resource etag. + :vartype etag: dict[str, str] + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.Kind :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.applicationinsights.v2021_03_08.models.SystemData - :param display_name: The user-defined name of the private workbook. - :type display_name: str - :param serialized_data: Configuration of this particular private workbook. Configuration data - is a string containing valid JSON. - :type serialized_data: str - :param version: This instance's version of the data model. This can change as new features are + :ivar display_name: The user-defined name of the private workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular private workbook. Configuration data is + a string containing valid JSON. + :vartype serialized_data: str + :ivar version: This instance's version of the data model. This can change as new features are added that can be marked private workbook. - :type version: str + :vartype version: str :ivar time_modified: Date and time in UTC of the last modification that was made to this private workbook definition. :vartype time_modified: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this private + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: A list of 0 or more tags that are associated with this private workbook definition. - :type tags_properties_tags: list[str] + :vartype tags_properties_tags: list[str] :ivar user_id: Unique user id of the specific user that owns this private workbook. :vartype user_id: str - :param source_id: Optional resourceId for a source resource. - :type source_id: str - :param storage_uri: BYOS Storage Account URI. - :type storage_uri: str + :ivar source_id: Optional resourceId for a source resource. + :vartype source_id: str + :ivar storage_uri: BYOS Storage Account URI. + :vartype storage_uri: str """ _validation = { @@ -221,6 +242,43 @@ def __init__( storage_uri: Optional[str] = None, **kwargs ): + """ + :keyword identity: Identity used for BYOS. + :paramtype identity: + ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentity + :keyword id: Azure resource Id. + :paramtype id: str + :keyword name: Azure resource name. + :paramtype name: str + :keyword type: Azure resource type. + :paramtype type: str + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword etag: Resource etag. + :paramtype etag: dict[str, str] + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.Kind + :keyword display_name: The user-defined name of the private workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular private workbook. Configuration data + is a string containing valid JSON. + :paramtype serialized_data: str + :keyword version: This instance's version of the data model. This can change as new features + are added that can be marked private workbook. + :paramtype version: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: A list of 0 or more tags that are associated with this private + workbook definition. + :paramtype tags_properties_tags: list[str] + :keyword source_id: Optional resourceId for a source resource. + :paramtype source_id: str + :keyword storage_uri: BYOS Storage Account URI. + :paramtype storage_uri: str + """ super(MyWorkbook, self).__init__(identity=identity, id=id, name=name, type=type, location=location, tags=tags, etag=etag, **kwargs) self.kind = kind self.system_data = None @@ -238,8 +296,8 @@ def __init__( class MyWorkbookError(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.applicationinsights.v2021_03_08.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.applicationinsights.v2021_03_08.models.ErrorDefinition """ _attribute_map = { @@ -252,6 +310,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.applicationinsights.v2021_03_08.models.ErrorDefinition + """ super(MyWorkbookError, self).__init__(**kwargs) self.error = error @@ -259,11 +321,11 @@ def __init__( class MyWorkbookManagedIdentity(msrest.serialization.Model): """Customer Managed Identity. - :param user_assigned_identities: Customer Managed Identity. - :type user_assigned_identities: + :ivar user_assigned_identities: Customer Managed Identity. + :vartype user_assigned_identities: ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookUserAssignedIdentities - :param type: The identity type. Possible values include: "UserAssigned", "None". - :type type: str or + :ivar type: The identity type. Possible values include: "UserAssigned", "None". + :vartype type: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentityType """ @@ -279,6 +341,14 @@ def __init__( type: Optional[Union[str, "MyWorkbookManagedIdentityType"]] = None, **kwargs ): + """ + :keyword user_assigned_identities: Customer Managed Identity. + :paramtype user_assigned_identities: + ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookUserAssignedIdentities + :keyword type: The identity type. Possible values include: "UserAssigned", "None". + :paramtype type: str or + ~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbookManagedIdentityType + """ super(MyWorkbookManagedIdentity, self).__init__(**kwargs) self.user_assigned_identities = user_assigned_identities self.type = type @@ -291,8 +361,8 @@ class MyWorkbooksListResult(msrest.serialization.Model): :ivar value: An array of private workbooks. :vartype value: list[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbook] - :param next_link: - :type next_link: str + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -310,6 +380,10 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: + :paramtype next_link: str + """ super(MyWorkbooksListResult, self).__init__(**kwargs) self.value = None self.next_link = next_link @@ -340,6 +414,8 @@ def __init__( self, **kwargs ): + """ + """ super(MyWorkbookUserAssignedIdentities, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -348,21 +424,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or + ~azure.mgmt.applicationinsights.v2021_03_08.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.applicationinsights.v2021_03_08.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -385,6 +462,24 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or + ~azure.mgmt.applicationinsights.v2021_03_08.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.applicationinsights.v2021_03_08.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py index 1dc7ef58ce164..ab5787a79ab4e 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_03_08/operations/_my_workbooks_operations.py @@ -5,23 +5,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + if source_id is not None: + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + *, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + source_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if source_id is not None: + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + source_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if source_id is not None: + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class MyWorkbooksOperations(object): """MyWorkbooksOperations operations. @@ -45,16 +297,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - category, # type: Union[str, "_models.CategoryType"] - tags=None, # type: Optional[List[str]] - source_id=None, # type: Optional[str] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MyWorkbooksListResult"] + resource_group_name: str, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.MyWorkbooksListResult"]: """Get all private workbooks defined within a specified resource group and category. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,8 +321,10 @@ def list_by_resource_group( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -78,42 +332,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,25 +377,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace def list_by_subscription( self, - category, # type: Union[str, "_models.CategoryType"] - tags=None, # type: Optional[List[str]] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MyWorkbooksListResult"] + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.MyWorkbooksListResult"]: """Get all private workbooks defined within a specified subscription and category. :param category: Category of workbook to return. @@ -155,8 +407,10 @@ def list_by_subscription( applicable workbook. If false, only return summary content for workbooks. :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MyWorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] + :return: An iterator like instance of either MyWorkbooksListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_03_08.models.MyWorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MyWorkbooksListResult"] @@ -164,39 +418,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MyWorkbooksListResult', pipeline_response) + deserialized = self._deserialize("MyWorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -209,24 +459,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MyWorkbook" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.MyWorkbook": """Get a single private workbook by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -243,33 +494,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -278,15 +519,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Delete a private workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -303,33 +546,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -337,15 +570,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_properties, # type: "_models.MyWorkbook" - source_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.MyWorkbook" + resource_group_name: str, + resource_name: str, + workbook_properties: "_models.MyWorkbook", + source_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.MyWorkbook": """Create a new private workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -367,40 +601,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'MyWorkbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -413,17 +636,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_properties, # type: "_models.MyWorkbook" - source_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.MyWorkbook" + resource_group_name: str, + resource_name: str, + workbook_properties: "_models.MyWorkbook", + source_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.MyWorkbook": """Updates a private workbook that has already been added. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -445,40 +670,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-08" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'MyWorkbook') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'MyWorkbook') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.MyWorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MyWorkbook', pipeline_response) @@ -487,4 +701,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py index 112bf3dc8852f..5f2c8fe4fd3c6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationInsightsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py index 4d18cef3f44cf..7169f1d75e280 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_application_insights_management_client.py @@ -6,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import WorkbooksOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations @@ -32,47 +30,52 @@ class ApplicationInsightsManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py index 8ff63f18b4ad8..a087a11536122 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class ApplicationInsightsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json index 4c9ffd52c4b26..d755963f73658 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationInsightsManagementClient", "filename": "_application_insights_management_client", "description": "Composite Swagger for Application Insights Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationInsightsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "workbooks": "WorkbooksOperations" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_vendor.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py index 48944bf3938a2..e5754a47ce68f 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py index 71e898dd88afa..ea847527db032 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_insights_management_client import ApplicationInsightsManagementClient __all__ = ['ApplicationInsightsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py index e00ff2fbe96cd..b6104c5b3edc6 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_application_insights_management_client.py @@ -6,69 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import ApplicationInsightsManagementClientConfiguration from .operations import WorkbooksOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ApplicationInsightsManagementClient(object): +class ApplicationInsightsManagementClient: """Composite Swagger for Application Insights Management Client. :ivar workbooks: WorkbooksOperations operations - :vartype workbooks: azure.mgmt.applicationinsights.v2021_08_01.aio.operations.WorkbooksOperations + :vartype workbooks: + azure.mgmt.applicationinsights.v2021_08_01.aio.operations.WorkbooksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationInsightsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationInsightsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) - self.workbooks = WorkbooksOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py index 4dd9be4678f19..67e1d54f3468b 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApplicationInsightsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_patch.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py index 82964dd6c844d..0078c59b49f96 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/aio/operations/_workbooks_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._workbooks_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_revision_get_request, build_revisions_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, category: Union[str, "_models.CategoryType"], @@ -59,7 +65,8 @@ def list_by_subscription( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -67,39 +74,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,17 +115,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -147,7 +152,8 @@ def list_by_resource_group( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -155,42 +161,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -203,17 +206,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -236,33 +241,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -271,8 +266,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -295,33 +293,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -329,6 +317,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -357,40 +347,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'Workbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -403,8 +382,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -423,7 +405,8 @@ async def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. - :type workbook_update_parameters: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook @@ -434,43 +417,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if workbook_update_parameters is not None: - body_content = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') + _json = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -479,8 +451,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def revisions_list( self, resource_group_name: str, @@ -495,7 +470,8 @@ def revisions_list( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -503,36 +479,33 @@ def revisions_list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.revisions_list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_revisions_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.revisions_list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_revisions_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -545,17 +518,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) revisions_list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions'} # type: ignore + @distributed_trace_async async def revision_get( self, resource_group_name: str, @@ -581,34 +556,24 @@ async def revision_get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - - # Construct URL - url = self.revision_get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'revisionId': self._serialize.url("revision_id", revision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revision_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + revision_id=revision_id, + template_url=self.revision_get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -617,4 +582,6 @@ async def revision_get( return cls(pipeline_response, deserialized, {}) return deserialized + revision_get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}'} # type: ignore + diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py index d13e41e13d7d7..41cedc3103254 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/__init__.py @@ -6,34 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ManagedServiceIdentity - from ._models_py3 import Resource - from ._models_py3 import SystemData - from ._models_py3 import TrackedResource - from ._models_py3 import UserAssignedIdentity - from ._models_py3 import Workbook - from ._models_py3 import WorkbookError - from ._models_py3 import WorkbookErrorDefinition - from ._models_py3 import WorkbookInnerErrorTrace - from ._models_py3 import WorkbookResource - from ._models_py3 import WorkbookResourceIdentity - from ._models_py3 import WorkbookUpdateParameters - from ._models_py3 import WorkbooksListResult -except (SyntaxError, ImportError): - from ._models import ManagedServiceIdentity # type: ignore - from ._models import Resource # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import UserAssignedIdentity # type: ignore - from ._models import Workbook # type: ignore - from ._models import WorkbookError # type: ignore - from ._models import WorkbookErrorDefinition # type: ignore - from ._models import WorkbookInnerErrorTrace # type: ignore - from ._models import WorkbookResource # type: ignore - from ._models import WorkbookResourceIdentity # type: ignore - from ._models import WorkbookUpdateParameters # type: ignore - from ._models import WorkbooksListResult # type: ignore +from ._models_py3 import ManagedServiceIdentity +from ._models_py3 import Resource +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import Workbook +from ._models_py3 import WorkbookError +from ._models_py3 import WorkbookErrorDefinition +from ._models_py3 import WorkbookInnerErrorTrace +from ._models_py3 import WorkbookResource +from ._models_py3 import WorkbookResourceIdentity +from ._models_py3 import WorkbookUpdateParameters +from ._models_py3 import WorkbooksListResult + from ._application_insights_management_client_enums import ( CategoryType, diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_application_insights_management_client_enums.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_application_insights_management_client_enums.py index e361043951148..6c2bf06e6e985 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_application_insights_management_client_enums.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_application_insights_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CategoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WORKBOOK = "workbook" TSG = "TSG" PERFORMANCE = "performance" RETENTION = "retention" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -42,14 +27,14 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class Kind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of workbook. Choices are user and shared. """ USER = "user" SHARED = "shared" -class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). """ @@ -59,7 +44,7 @@ class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, E USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class SharedTypeKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SharedTypeKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of workbook. Choices are user and shared. """ diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models.py deleted file mode 100644 index ed87c062ee6dd..0000000000000 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models.py +++ /dev/null @@ -1,582 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ManagedServiceIdentity(msrest.serialization.Model): - """Managed service identity (system assigned and/or user assigned identities). - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :param type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". - :type type: str or - ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType - :param user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :type user_assigned_identities: dict[str, - ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedServiceIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs['type'] - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or - ~azure.mgmt.applicationinsights.v2021_08_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class UserAssignedIdentity(msrest.serialization.Model): - """User assigned identity properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of the assigned identity. - :vartype principal_id: str - :ivar client_id: The client ID of the assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAssignedIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class WorkbookResource(TrackedResource): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind - :param etag: Resource etag. - :type etag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'WorkbookResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookResource, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.kind = kwargs.get('kind', None) - self.etag = kwargs.get('etag', None) - - -class Workbook(WorkbookResource): - """An Application Insights workbook definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind - :param etag: Resource etag. - :type etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.applicationinsights.v2021_08_01.models.SystemData - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a - string containing valid JSON. - :type serialized_data: str - :param version: Workbook schema version format, like 'Notebook/1.0', which should match the - workbook in serializedData. - :type version: str - :ivar time_modified: Date and time in UTC of the last modification that was made to this - workbook definition. - :vartype time_modified: ~datetime.datetime - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: Being deprecated, please use the other tags field. - :type tags_properties_tags: list[str] - :ivar user_id: Unique user id of the specific user that owns this workbook. - :vartype user_id: str - :param source_id: ResourceId for a source resource. - :type source_id: str - :param storage_uri: The resourceId to the storage account when bring your own storage is used. - :type storage_uri: str - :param description: The description of the workbook. - :type description: str - :ivar revision: The unique revision id for this workbook definition. - :vartype revision: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'time_modified': {'readonly': True}, - 'user_id': {'readonly': True}, - 'revision': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'WorkbookResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'time_modified': {'key': 'properties.timeModified', 'type': 'iso-8601'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'tags_properties_tags': {'key': 'properties.tags', 'type': '[str]'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - 'source_id': {'key': 'properties.sourceId', 'type': 'str'}, - 'storage_uri': {'key': 'properties.storageUri', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Workbook, self).__init__(**kwargs) - self.system_data = None - self.display_name = kwargs.get('display_name', None) - self.serialized_data = kwargs.get('serialized_data', None) - self.version = kwargs.get('version', None) - self.time_modified = None - self.category = kwargs.get('category', None) - self.tags_properties_tags = kwargs.get('tags_properties_tags', None) - self.user_id = None - self.source_id = kwargs.get('source_id', None) - self.storage_uri = kwargs.get('storage_uri', None) - self.description = kwargs.get('description', None) - self.revision = None - - -class WorkbookError(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'WorkbookErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class WorkbookErrorDefinition(msrest.serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar inner_error: Internal error details. - :vartype inner_error: any - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'inner_error': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'inner_error': {'key': 'innerError', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookErrorDefinition, self).__init__(**kwargs) - self.code = None - self.message = None - self.inner_error = None - - -class WorkbookInnerErrorTrace(msrest.serialization.Model): - """Error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar trace: detailed error trace. - :vartype trace: list[str] - """ - - _validation = { - 'trace': {'readonly': True}, - } - - _attribute_map = { - 'trace': {'key': 'trace', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookInnerErrorTrace, self).__init__(**kwargs) - self.trace = None - - -class WorkbookResourceIdentity(ManagedServiceIdentity): - """Identity used for BYOS. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :param type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". - :type type: str or - ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType - :param user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :type user_assigned_identities: dict[str, - ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookResourceIdentity, self).__init__(**kwargs) - - -class WorkbooksListResult(msrest.serialization.Model): - """Workbook list result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: An array of workbooks. - :vartype value: list[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] - :param next_link: - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Workbook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbooksListResult, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class WorkbookUpdateParameters(msrest.serialization.Model): - """The parameters that can be provided when updating workbook properties properties. - - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.SharedTypeKind - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a - string containing valid JSON. - :type serialized_data: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook - definition. - :type tags_properties_tags: list[str] - :param description: The description of the workbook. - :type description: str - :param revision: The unique revision id for this workbook definition. - :type revision: str - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'serialized_data': {'key': 'properties.serializedData', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'tags_properties_tags': {'key': 'properties.tags', 'type': '[str]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkbookUpdateParameters, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.tags = kwargs.get('tags', None) - self.display_name = kwargs.get('display_name', None) - self.serialized_data = kwargs.get('serialized_data', None) - self.category = kwargs.get('category', None) - self.tags_properties_tags = kwargs.get('tags_properties_tags', None) - self.description = kwargs.get('description', None) - self.revision = kwargs.get('revision', None) diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py index e869566a108e7..ebc61565f31af 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/models/_models_py3.py @@ -28,16 +28,16 @@ class ManagedServiceIdentity(msrest.serialization.Model): :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :param type: Required. Type of managed service identity (where both SystemAssigned and + :ivar type: Required. Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". - :type type: str or + :vartype type: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType - :param user_assigned_identities: The set of user assigned identities associated with the + :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] """ @@ -61,6 +61,19 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, **kwargs ): + """ + :keyword type: Required. Type of managed service identity (where both SystemAssigned and + UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", + "UserAssigned", "SystemAssigned,UserAssigned". + :paramtype type: str or + ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] + """ super(ManagedServiceIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -99,6 +112,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -108,21 +123,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or + ~azure.mgmt.applicationinsights.v2021_08_01.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -145,6 +161,24 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or + ~azure.mgmt.applicationinsights.v2021_08_01.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.applicationinsights.v2021_08_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -169,10 +203,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -197,6 +231,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -227,6 +267,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -247,17 +289,17 @@ class WorkbookResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind - :param etag: Resource etag. - :type etag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar identity: Identity used for BYOS. + :vartype identity: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind + :ivar etag: Resource etag. + :vartype etag: str """ _validation = { @@ -288,6 +330,20 @@ def __init__( etag: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword identity: Identity used for BYOS. + :paramtype identity: + ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind + :keyword etag: Resource etag. + :paramtype etag: str + """ super(WorkbookResource, self).__init__(tags=tags, location=location, **kwargs) self.identity = identity self.kind = kind @@ -309,42 +365,42 @@ class Workbook(WorkbookResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Identity used for BYOS. - :type identity: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind - :param etag: Resource etag. - :type etag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar identity: Identity used for BYOS. + :vartype identity: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind + :ivar etag: Resource etag. + :vartype etag: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.applicationinsights.v2021_08_01.models.SystemData - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a + :ivar display_name: The user-defined name (display name) of the workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a string containing valid JSON. - :type serialized_data: str - :param version: Workbook schema version format, like 'Notebook/1.0', which should match the + :vartype serialized_data: str + :ivar version: Workbook schema version format, like 'Notebook/1.0', which should match the workbook in serializedData. - :type version: str + :vartype version: str :ivar time_modified: Date and time in UTC of the last modification that was made to this workbook definition. :vartype time_modified: ~datetime.datetime - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: Being deprecated, please use the other tags field. - :type tags_properties_tags: list[str] + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: Being deprecated, please use the other tags field. + :vartype tags_properties_tags: list[str] :ivar user_id: Unique user id of the specific user that owns this workbook. :vartype user_id: str - :param source_id: ResourceId for a source resource. - :type source_id: str - :param storage_uri: The resourceId to the storage account when bring your own storage is used. - :type storage_uri: str - :param description: The description of the workbook. - :type description: str + :ivar source_id: ResourceId for a source resource. + :vartype source_id: str + :ivar storage_uri: The resourceId to the storage account when bring your own storage is used. + :vartype storage_uri: str + :ivar description: The description of the workbook. + :vartype description: str :ivar revision: The unique revision id for this workbook definition. :vartype revision: str """ @@ -401,6 +457,39 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword identity: Identity used for BYOS. + :paramtype identity: + ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookResourceIdentity + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.Kind + :keyword etag: Resource etag. + :paramtype etag: str + :keyword display_name: The user-defined name (display name) of the workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword version: Workbook schema version format, like 'Notebook/1.0', which should match the + workbook in serializedData. + :paramtype version: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: Being deprecated, please use the other tags field. + :paramtype tags_properties_tags: list[str] + :keyword source_id: ResourceId for a source resource. + :paramtype source_id: str + :keyword storage_uri: The resourceId to the storage account when bring your own storage is + used. + :paramtype storage_uri: str + :keyword description: The description of the workbook. + :paramtype description: str + """ super(Workbook, self).__init__(tags=tags, location=location, identity=identity, kind=kind, etag=etag, **kwargs) self.system_data = None self.display_name = display_name @@ -419,8 +508,8 @@ def __init__( class WorkbookError(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookErrorDefinition """ _attribute_map = { @@ -433,6 +522,10 @@ def __init__( error: Optional["WorkbookErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookErrorDefinition + """ super(WorkbookError, self).__init__(**kwargs) self.error = error @@ -466,6 +559,8 @@ def __init__( self, **kwargs ): + """ + """ super(WorkbookErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -493,6 +588,8 @@ def __init__( self, **kwargs ): + """ + """ super(WorkbookInnerErrorTrace, self).__init__(**kwargs) self.trace = None @@ -510,16 +607,16 @@ class WorkbookResourceIdentity(ManagedServiceIdentity): :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :param type: Required. Type of managed service identity (where both SystemAssigned and + :ivar type: Required. Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". - :type type: str or + :vartype type: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType - :param user_assigned_identities: The set of user assigned identities associated with the + :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] """ @@ -543,6 +640,19 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, **kwargs ): + """ + :keyword type: Required. Type of managed service identity (where both SystemAssigned and + UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", + "UserAssigned", "SystemAssigned,UserAssigned". + :paramtype type: str or + ~azure.mgmt.applicationinsights.v2021_08_01.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.applicationinsights.v2021_08_01.models.UserAssignedIdentity] + """ super(WorkbookResourceIdentity, self).__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) @@ -553,8 +663,8 @@ class WorkbooksListResult(msrest.serialization.Model): :ivar value: An array of workbooks. :vartype value: list[~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook] - :param next_link: - :type next_link: str + :ivar next_link: + :vartype next_link: str """ _validation = { @@ -572,6 +682,10 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: + :paramtype next_link: str + """ super(WorkbooksListResult, self).__init__(**kwargs) self.value = None self.next_link = next_link @@ -580,25 +694,25 @@ def __init__( class WorkbookUpdateParameters(msrest.serialization.Model): """The parameters that can be provided when updating workbook properties properties. - :param kind: The kind of workbook. Choices are user and shared. Possible values include: - "user", "shared". - :type kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.SharedTypeKind - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param display_name: The user-defined name (display name) of the workbook. - :type display_name: str - :param serialized_data: Configuration of this particular workbook. Configuration data is a + :ivar kind: The kind of workbook. Choices are user and shared. Possible values include: "user", + "shared". + :vartype kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.SharedTypeKind + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar display_name: The user-defined name (display name) of the workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a string containing valid JSON. - :type serialized_data: str - :param category: Workbook category, as defined by the user at creation time. - :type category: str - :param tags_properties_tags: A list of 0 or more tags that are associated with this workbook + :vartype serialized_data: str + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: A list of 0 or more tags that are associated with this workbook definition. - :type tags_properties_tags: list[str] - :param description: The description of the workbook. - :type description: str - :param revision: The unique revision id for this workbook definition. - :type revision: str + :vartype tags_properties_tags: list[str] + :ivar description: The description of the workbook. + :vartype description: str + :ivar revision: The unique revision id for this workbook definition. + :vartype revision: str """ _attribute_map = { @@ -625,6 +739,27 @@ def __init__( revision: Optional[str] = None, **kwargs ): + """ + :keyword kind: The kind of workbook. Choices are user and shared. Possible values include: + "user", "shared". + :paramtype kind: str or ~azure.mgmt.applicationinsights.v2021_08_01.models.SharedTypeKind + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword display_name: The user-defined name (display name) of the workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: A list of 0 or more tags that are associated with this workbook + definition. + :paramtype tags_properties_tags: list[str] + :keyword description: The description of the workbook. + :paramtype description: str + :keyword revision: The unique revision id for this workbook definition. + :paramtype revision: str + """ super(WorkbookUpdateParameters, self).__init__(**kwargs) self.kind = kind self.tags = tags diff --git a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py index 03ee629c6dbc3..e0cf8b44fd8b5 100644 --- a/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py +++ b/sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2021_08_01/operations/_workbooks_operations.py @@ -5,23 +5,347 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + *, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['category'] = _SERIALIZER.query("category", category, 'str') + if tags is not None: + query_parameters['tags'] = _SERIALIZER.query("tags", tags, '[str]', div=',') + if source_id is not None: + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + if can_fetch_content is not None: + query_parameters['canFetchContent'] = _SERIALIZER.query("can_fetch_content", can_fetch_content, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + source_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if source_id is not None: + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + source_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if source_id is not None: + query_parameters['sourceId'] = _SERIALIZER.query("source_id", source_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_revisions_list_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_revision_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + revision_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "revisionId": _SERIALIZER.url("revision_id", revision_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WorkbooksOperations(object): """WorkbooksOperations operations. @@ -45,14 +369,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - category, # type: Union[str, "_models.CategoryType"] - tags=None, # type: Optional[List[str]] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkbooksListResult"] + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.WorkbooksListResult"]: """Get all private workbooks defined within a specified subscription and category. :param category: Category of workbook to return. @@ -64,7 +388,8 @@ def list_by_subscription( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -72,39 +397,35 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,27 +438,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - category, # type: Union[str, "_models.CategoryType"] - tags=None, # type: Optional[List[str]] - source_id=None, # type: Optional[str] - can_fetch_content=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkbooksListResult"] + resource_group_name: str, + category: Union[str, "_models.CategoryType"], + tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.WorkbooksListResult"]: """Get all Workbooks defined within a specified resource group and category. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -153,7 +475,8 @@ def list_by_resource_group( :type can_fetch_content: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -161,42 +484,39 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['category'] = self._serialize.query("category", category, 'str') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - if can_fetch_content is not None: - query_parameters['canFetchContent'] = self._serialize.query("can_fetch_content", can_fetch_content, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -209,24 +529,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.Workbook": """Get a single workbook by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -243,33 +564,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -278,15 +589,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> None: """Delete a workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -303,33 +616,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -337,15 +640,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - workbook_properties, # type: "_models.Workbook" - source_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + workbook_properties: "_models.Workbook", + source_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.Workbook": """Create a new workbook. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -366,40 +670,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workbook_properties, 'Workbook') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(workbook_properties, 'Workbook') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -412,17 +705,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - source_id=None, # type: Optional[str] - workbook_update_parameters=None, # type: Optional["_models.WorkbookUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + source_id: Optional[str] = None, + workbook_update_parameters: Optional["_models.WorkbookUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.Workbook": """Updates a workbook that has already been added. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -433,7 +728,8 @@ def update( :type source_id: str :param workbook_update_parameters: Properties that need to be specified to create a new workbook. - :type workbook_update_parameters: ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbookUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: Workbook, or the result of cls(response) :rtype: ~azure.mgmt.applicationinsights.v2021_08_01.models.Workbook @@ -444,43 +740,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if source_id is not None: - query_parameters['sourceId'] = self._serialize.query("source_id", source_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if workbook_update_parameters is not None: - body_content = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') + _json = self._serialize.body(workbook_update_parameters, 'WorkbookUpdateParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + source_id=source_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -489,15 +774,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}'} # type: ignore + + @distributed_trace def revisions_list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkbooksListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkbooksListResult"]: """Get the revisions for the workbook defined by its resourceName. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -506,7 +793,8 @@ def revisions_list( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkbooksListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.v2021_08_01.models.WorkbooksListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkbooksListResult"] @@ -514,36 +802,33 @@ def revisions_list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.revisions_list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_revisions_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.revisions_list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_revisions_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkbooksListResult', pipeline_response) + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,25 +841,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) revisions_list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions'} # type: ignore + @distributed_trace def revision_get( self, - resource_group_name, # type: str - resource_name, # type: str - revision_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Workbook" + resource_group_name: str, + resource_name: str, + revision_id: str, + **kwargs: Any + ) -> "_models.Workbook": """Get a single workbook revision defined by its revisionId. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -593,34 +879,24 @@ def revision_get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-01" - accept = "application/json" - - # Construct URL - url = self.revision_get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'revisionId': self._serialize.url("revision_id", revision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revision_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + revision_id=revision_id, + template_url=self.revision_get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.WorkbookError, response) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Workbook', pipeline_response) @@ -629,4 +905,6 @@ def revision_get( return cls(pipeline_response, deserialized, {}) return deserialized + revision_get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}'} # type: ignore +